I’m not sure why google let me down in regards to hooking up logstash and Play, but it sent me on some pretty weird paths. So I’m going to share what we did to get it working that is pretty simple in the end.
Play uses logback, first rule is don’t try to include a new version of logback in your build, that will cause you conflicts, the ootb Play dependencies are all you need, at the time I did this, we were using Play 2.3.8.
In your logback config, logger.xml, just wire up the appender you want, the tcp or udp one like this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!– for udp –> | |
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashSocketAppender"> | |
<host>logstash_server/host> | |
<port>logstash_port</port> | |
<encoder class="net.logstash.logback.encoder.LogstashEncoder" /> | |
</appender> | |
<!– for tcp –> | |
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender"> | |
<host>logstash_server/host> | |
<port>logstash_port</port> | |
<encoder class="net.logstash.logback.encoder.LogstashEncoder" /> | |
</appender> | |
<!– include the appender –> | |
<root level="INFO"> | |
<appender-ref ref="LOGSTASH" /> | |
</root> |
Then on the logstash config side create a new input:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
udp { | |
codec => json | |
port => XXXX | |
type => logback | |
} | |
} |
This puts your data into a new type (called “logstash”) in the ES indices so that the json mappings don’t conflict with anything else. That’s it.