如何让 Akka 了解 Play 的 logback 配置(application-logger.xml)?
在我的情况下,它被完全忽略:
日志仅打印到标准输出。我希望它被记录到 application-logger.xml 中定义的 File-Appender
如果我将 application-logger.xml 重命名为 logback.xml 并没有什么不同。
演员等级:
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>