当我将 Play 2 应用程序部署到 Heroku 时,我可以从“heroku 日志”中看到以下日志。
2012-07-05T10:13:08+00:00 app[web.1]: Play server process ID is 3
2012-07-05T10:13:08+00:00 app[web.1]: SLF4J: Class path contains multiple SLF4J bindings.
2012-07-05T10:13:08+00:00 app[web.1]: SLF4J: Found binding in [jar:file:/app/target/staged/slf4j-log4j12-1.6.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
2012-07-05T10:13:08+00:00 app[web.1]: SLF4J: Found binding in [jar:file:/app/target/staged/logback-classic-1.0.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
2012-07-05T10:13:08+00:00 app[web.1]: SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
2012-07-05T10:13:09+00:00 app[web.1]: log4j:WARN No appenders could be found for logger (com.jolbox.bonecp.BoneCPDataSource).
2012-07-05T10:13:09+00:00 app[web.1]: log4j:WARN Please initialize the log4j system properly.
2012-07-05T10:13:09+00:00 app[web.1]: log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
当我尝试从 Play 应用程序打印日志时,我无法从 heroku 日志输出中获取它。这是我的播放日志配置。
# Logger used by the framework:
logger.play=INFO
# Logger provided to your application:
logger.application=DEBUG
我在 Play 2 java 类中使用的日志语句:
play.Logger.debug("log output......");
更新 1 这是我为解决多个依赖项问题所做的。
("com.jayway.facebooktestjavaapi" % "facebook-test-java-api" % "1.1.5" notTransitive()).exclude("org.slf4j", "slf4j-log4j12")
更新 2 在我解决了上述错误之后,日志语句仍然没有输出到“heroku 日志”。所以我在这里(https://github.com/playframework/Play20/wiki/SettingsLogger)设置logger.xml。但它仍然没有输出任何东西。
$ vi conf/application.conf
logger.resource=dev-logger.xml
db.default.logStatements=true
$ cat conf/dev-logger.xml
<configuration>
<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$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 %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="TRACE" />
<logger name="application" level="TRACE" />
<root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
更新 3 我将所有内容还原并使用原始应用程序日志,但仍未输出。
# Root logger:
logger.root=DEBUG
# Logger used by the framework:
logger.play=DEBUG
# Logger provided to your application:
logger.application=DEBUG
# Logger ebean
logger.com.jolbox=DEBUG