I have an Akka Actor that makes a call to MyObject.foo(). MyObject is not an Actor. How do I setup Logging in it? With an Actor it’s simple, because I can just mixin ActorLogging. In MyObject, I don’t have access to context.system. Do I create an akka.event.Logging with AkkaSystem() and then what for the LogSource implicit?
I have an Akka Actor that makes a call to MyObject.foo() . MyObject is
Share
Actually I would redirect Akka logging to slf4j and use this API directly in all unrelated classes. First add this to your configuration:
Then choose some SLF4J implementation, I suggest logback. In your actors continue using
ActorLoggingtrait. In other classes simply rely on SLF4J API – or even better – try out slf4s facade around SLF4J.Tip: try out the following logging pattern in Logback:
The
%X{akkaSource}will print actor path when available (just like standard logging).