我的播放代码中的日志记录工作正常,但是我所拥有的akka代码未记录到文件/标准输出中.
My logging is working fine from within my play code, but the akka code I have isn't logging to file/stdout.
class EmailActor extends Actor with ActorLogging { import EmailActor._ log.info("email actor hatched..") ... }创建此actor时,在日志文件或stdout中都看不到日志记录条目.
When I create this actor I don't see the logging entries in either the log file or stdout.
我具有此激活器模板的默认application.conf: github/playframework/play-scala/blob/master/conf/logback.xml
I have the default application.conf from this activator template: github/playframework/play-scala/blob/master/conf/logback.xml
我是否需要使用akka标签修改登录文件?
Do I need to modify my logback file with some akka label?
更新
我现在在我的application.conf中完成了此操作:
I have done this now in my application.conf:
akka { loggers = ["akka.event.slf4j.Slf4jLogger"] #loggers = ["akka.event.Logging$DefaultLogger"] loglevel = "DEBUG" logging-filter = "akka.event.slf4j.Slf4jLoggingFilter" actor { debug { lifecycle = on } } }在我的依赖项中,我已经添加了这个(并且都添加到了我的play应用的dep中):
In my dependencies I have added this (and are both added to my play app's dep):
val akkaSlf4j = "com.typesafe.akka" %% "akka-slf4j" % Version.akkaSlf4j val logback = "ch.qos.logback" % "logback-classic" % Version.logback我的logback.xml看起来像:
My logback.xml looks like:
<!-- www.playframework/documentation/latest/SettingsLogger --> <configuration> <conversionRule conversionWord="coloredLevel" converterClass="play.api.libs.logback.ColoredLevel" /> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>${application.home:-.}/logs/application.log</file> <encoder> <pattern>%date [%level] from %logger in %thread - %message%n%xException</pattern> </encoder> </appender> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%coloredLevel %logger{15} - %message%n%xException{10}</pattern> </encoder> </appender> <appender name="ASYNCFILE" class="ch.qos.logback.classic.AsyncAppender"> <appender-ref ref="FILE" /> </appender> <appender name="ASYNCSTDOUT" class="ch.qos.logback.classic.AsyncAppender"> <appender-ref ref="STDOUT" /> </appender> <logger name="play" level="INFO" /> <logger name="application" level="DEBUG" /> <!-- Off these ones as they are annoying, and anyway we manage configuration ourselves --> <logger name="com.avaje.ebean.config.PropertyMapLoader" level="OFF" /> <logger name="com.avaje.ebeaninternal.server.core.XmlConfigLoader" level="OFF" /> <logger name="com.avaje.ebeaninternal.server.lib.BackgroundThread" level="OFF" /> <logger name="com.gargoylesoftware.htmlunit.javascript" level="OFF" /> <root level="WARN"> <appender-ref ref="ASYNCFILE" /> <appender-ref ref="ASYNCSTDOUT" /> </root> </configuration>我没有在STDOUT或使用ActorLogging日志方法创建的日志文件中看到任何与akka相关的日志.
I do not see any akka related logs in STDOUT or in my log files that I create using the ActorLogging log method.
推荐答案请注意您的logback.xml如何包含这一行,
Notice how your logback.xml has this line,
<logger name="play" level="INFO" />允许loger_name等于播放"的记录器以INFO级别记录.
which allows a logger with loger_name equal to "play" to log at INFO level.
类似地,您需要将以下内容添加到logback.xml中,
Similarly, you will need to add the following to your logback.xml,
<logger name="akka.event.slf4j.Slf4jLogger" level="DEBUG" />更多推荐
为什么我的Akka日志无法在游戏中运行
发布评论