/ dev

Logging to Syslog from Play

If youʼre a Java developer, this is probably very obvious but, I had a very hard time figguring out how to do this. This probably has a lot to do with the difficulty of finding information about current versions of various products. We happen to be using Play 2.2.x and this is how you can do it.

<configuration>
  <appender name="SYSLOG" class="ch.qos.logback.classic.net.SyslogAppender">
    <syslogHost>localhost</syslogHost>
    <facility>User</facility>
    <suffixPattern>{{app_name}}: %logger{20} %message%n</suffixPattern>
  </appender>

  <logger name="play" level="INFO" />
  <logger name="application" level="INFO" />

  <root level="ERROR">
    <appender-ref ref="SYSLOG" />
  </root>
</configuration>

Replace {{app_name}} with the name of your app and then save it as conf/logger.xml and then run your app and it will log to the specified server. Note that this requires that you have syslog server listening over http. Logstashʼs syslog input works great for this.