Make Akka aware of Play Playback configuration

How do I make Akka aware of the Play logback configuration (application-logger.xml)?
In my case, this is completely ignored:

The journal is printed only on standard output. I expect it to be registered in the File-Appender defined in application-logger.xml

It doesn’t matter if I rename application-logger.xml to logback.xml.

Actor class:

class Dispatcher extends Actor with ActorLogging { // prints to stdout ONLY: log.error("[akka-logger] dispatch started...") } 

conf /application.conf:

 play { akka { #log-config-on-start = on loggers = ["akka.event.slf4j.Slf4jLogger"] event-handlers = ["akka.event.slf4j.Slf4jEventHandler"] loglevel = DEBUG # and so on... } 

conf / application logger.xml

 <configuration> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>${application.home}/logs/application.log</file> <encoder> <pattern>%date - [%level] - from %logger in %thread %n%message%n%xException%n</ pattern> </encoder> </appender> <!-- Using akka.event.slf4j.EventHandler does NOT make a difference here: --> <logger name="akka.event.slf4j.Slf4jLogger" level="ERROR" additivity="false"> <appender-ref ref="FILE"/> </logger> <logger name="play" level="ERROR" additivity="false"> <appender-ref ref="FILE"/> </logger> <logger name="application" level="ERROR" additivity="false"> <appender-ref ref="FILE"/> </logger> <root level="ERROR"> <appender-ref ref="STDOUT"/> <appender-ref ref="FILE"/> </root> </configuration> 
+7
source share
2 answers

I had the same problem. I use play 2.2.1 (also tested with 2.2.2) and an updated version of akka 2.2.3 (But it also works with the version that comes with the game). It should also be noted that I use Java not Scala. Here is what I did.

application.conf:

  akka { loggers = ["akka.event.slf4j.Slf4jLogger"] loglevel = "DEBUG" } 

And in my logger.xml it looks like this:

 <configuration> <conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" /> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>${application.home}/logs/applicationmax.log</file> <encoder> <pattern>%date ---- [%level] -- %X{akkaSource} -- from %logger in %thread %n%message%n%xException%n</pattern> </encoder> </appender> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%coloredLevel %logger{15} - %message%n%xException{5}</pattern> </encoder> </appender> <logger name="play" level="DEBUG" /> <logger name="application" level="DEBUG" /> <!-- use the package names of classes for specific loggers --> <logger name="actor" level="DEBUG" /> <root level="ERROR"> <appender-ref ref="STDOUT" /> <appender-ref ref="FILE" /> </root> </configuration> 

The main thing to note is that I use the name of the root package, where the actors are my registrar. You can be as specific as you, for example com.actors or com.actors.someactors, etc.

You can see more in this google group thread in the play-framework group:

Make Akka aware of Play Play configuration

+3
source

The default file name used during playback for the log, logger.xml - see link . You can also change the root level from error to debugging to make sure that you get any log messages at all at the root level.

-one
source

All Articles