简体   繁体   English

在Heroku上播放2.2生产模式

[英]Play 2.2 production mode logging on Heroku

I've deployed a Play 2.2 application on Heroku. 我在Heroku上部署了一个Play 2.2应用程序。 Currently, the messages written to my loggers in my app are not appearing in the Heroku log, as the Play app is (apparently) writing to something other than stdout. 目前,在我的应用程序中写入我的记录器的消息没有出现在Heroku日志中,因为Play应用程序(显然)正在写入除stdout之外的其他内容。

In development mode, my loggers are working fine (they write to stdout). 在开发模式下,我的记录器工作正常(他们写入stdout)。 I would like my application to write its logging to stdout in production mode as well, so it ends up in Heroku's application log. 我希望我的应用程序在生产模式下将其日志记录写入stdout,因此它最终会出现在Heroku的应用程序日志中。

Is there a change I have to make in the configuration of Play to make this happen? 在配置Play时我是否需要进行更改以实现此目的?

I created a file called conf/application-logger.xml in the application. 我在conf/application-logger.xml创建了一个名为conf/application-logger.xml的文件。 No other changes the application.conf were needed, and now the logging is working correctly on Heroku. 没有其他更改application.conf是必需的,现在日志记录在Heroku上正常工作。

http://www.playframework.com/documentation/2.2.x/SettingsLogger has these instructions. http://www.playframework.com/documentation/2.2.x/SettingsLogger有这些说明。 However, my configuration differs from the example on that page in that I removed the appender to FILE and kept only the appender to STDOUT appender. 但是,我的配置与该页面上的示例的不同之处在于我将appender移除到FILE并仅将appender保留到STDOUT appender。

<configuration>

  <conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />

  <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="INFO" />
  <logger name="application" level="INFO" />
  <logger name="mycustomlogger" level="INFO" />

  <!-- Off these ones as they are annoying, and anyway we manage configuration ourself -->
  <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="ERROR">
    <appender-ref ref="STDOUT" />
  </root>

</configuration>

我已经开始使用Papertrail Heroku附加组件https://addons.heroku.com/papertrail ,到目前为止对它非常满意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM