I'm configuring my Akka application to use the SLF4J logger as specified here:
http://doc.akka.io/docs/akka/2.3.4/scala/logging.html
Underneath the hood, I'm depending on Logback to do the logging. I'm developing a common module for logging purposes that users can use in their actor systems. Mainly, I'm creating a trait they can mixin.
I have a trait that does this:
I have something as such:
trait ActorLogger {
val log: DiagnosticLoggingAdapter = Logging(this);
}
I have some extra logic which will add MDC values to the DiagnosticLoggingAdapter's MDC. The problem is now this: I expose a different logger entirely if users want to mixin to their non-actor classes. So I might have something like this:
trait ClassLogger {
val log = LoggerFactory getLogger getClass.getName
}
I want the MDC values to carry over to this logger. So for example, if I put MDC values into my DiagnosticAdapterLogger, I should expect to be able to get those values from org.slf4j.MDC
How can this be achieved in a clean way?
Thanks!