The aka documentation for logging says that you can register handlers in config as follows:
akka { # Event handlers to register at boot time (Logging$DefaultLogger logs to STDOUT) event-handlers = ["akka.event.Logging$DefaultLogger"] # Options: ERROR, WARNING, INFO, DEBUG loglevel = "DEBUG" }
There is also a SLF4J handler
akka.event.slf4j.Slf4jEventHandler
With this, you can add any SLF4J compatible library, such as a journal, to record your journals wherever you want.
edit:
To use logback to enter the file, you need to add the login as a dependency, add Slf4jEventHandler to your configuration:
akka { # Event handlers to register at boot time (Logging$DefaultLogger logs to STDOUT) event-handlers = ["akka.event.slf4j.Slf4jEventHandler"] # Options: ERROR, WARNING, INFO, DEBUG loglevel = "DEBUG" }
and add the logback configuration to your project that projects something like this (taken from the log documentation):
<configuration> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>testFile.log</file> <append>true</append> <encoder> <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern> </encoder> </appender> <root level="DEBUG"> <appender-ref ref="FILE" /> </root> </configuration>
Due to asynchronous logging in akka, you cannot use the% thread variable in the log template, use the sourceThread
variable from MDC instead. You can read about it at the bottom of this page: http://doc.akka.io/docs/akka/2.0/scala/logging.html
You do not need to explicitly use slf4j or logback in your code, just use normal akka logging, the handler will take care of the rest.