/ 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.

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

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

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

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.