在我的play scala应用程序中,
log.info("...")
命令被忽略。
我咨询过以下内容:
Akka actor logging not writing to file
Play Akka logger doesn't output debug messages to console
Akka documentation on logging
我的相关内容
application.conf
文件包括:
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = "INFO"
log-config-on-start = on
}
...
和
logback.xml
:
<configuration>
<conversionRule conversionWord="coloredLevel" converterClass="play.api.libs.logback.ColoredLevel" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>/var/log/foo/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="INFO" />
<logger name="akka" level="INFO" />
<!-- 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>
在我的代码中,我有如下内容:
class MyActor extends Actor with ActorLogging {
override def receive = {
case msg =>
println("This should show up in the console")
log.info("log this message", msg)
}
}
然而,我的
application.log
文件不包含
log.info
命令,即使终端显示
println
命令:
2018-07-20 00:02:59,109 [INFO] from akka.event.slf4j.Slf4jLogger in application-akka.actor.default-dispatcher-4 - Slf4jLogger started
2018-07-20 00:02:59,145 [INFO] from akka.actor.ActorSystemImpl in application-akka.actor.default-dispatcher-4 - {
# merge of play/reference-overrides.conf @ jar:file:/root/.ivy2/cache/com.typesafe.play/play_2.11/jars/play_2.11-2.6.9.jar!/play/reference-overrides.conf: 20,reference.conf @ jar:file:/root/.ivy2/cache/com.typesafe.akka/akka-actor_2.11/jars/akka-actor_2.11-2.5.14.jar!/reference.conf: 92
"actor" : {
# reference.conf @ jar:file:/root/.ivy2/cache/com.typesafe.akka/akka-actor_2.11/jars/akka-actor_2.11-2.5.14.jar!/reference.conf: 717
# Additional serialization-bindings that are replacing Java serialization are
# defined in this section for backwards compatibility reasons. They are included
# by default but can be excluded for backwards compatibility with Akka 2.4.x.
...
# system properties
"user" : {
# system properties
"dir" : "/home",
# system properties
"home" : "/root",
# system properties
"language" : "en",
# system properties
"name" : "root",
# system properties
"timezone" : "Etc/UTC"
},
1/jars/akka-actor_2.11-2.5.14.jar!/version.conf: 1
"version" : "2.5.14"
}
ult-dispatcher-2 - Using the following cache for assets configuration:
enabledCaching = false
enabledCacheControl = false
defaultCacheControl = public, max-age=3600
aggressiveCacheControl = public, max-age=31536000, immutable
configuredCacheControl:
ork.com/documentation/latest/Filters>):
play.filters.csrf.CSRFFilter
play.filters.headers.SecurityHeadersFilter
play.filters.hosts.AllowedHostsFilter
fault-dispatcher-2 - Application started (Dev)
作为的内容
应用程序日志
显示,线条
log-config-on-start = on