How can I use the GELF appender with game 2.2.3?
I have a play-2.2.3 application. I would like to send logs to graylog2 server using GELF-TCP. I tried using the me.moocar GELF logback app but it seems that there are problems because it is compiled with some other version of the log core kernel.
Can I configure logback to send logs (over TCP or UDP) to a graylog2 instance hosted elsewhere?
+3
source to share
1 answer
You can try logstash-gelf . It supports TCP and UDP channels (UDP does not block). logstash-gelf is compiled against logback-classic version 1.0.13.
Configuration example:
<!DOCTYPE configuration>
<configuration>
<contextName>test</contextName>
<jmxConfigurator/>
<appender name="gelf" class="biz.paluch.logging.gelf.logback.GelfLogbackAppender">
<host>udp:localhost</host>
<port>12201</port>
<version>1.1</version>
<facility>java-test</facility>
<extractStackTrace>true</extractStackTrace>
<filterStackTrace>true</filterStackTrace>
<mdcProfiling>true</mdcProfiling>
<timestampPattern>yyyy-MM-dd HH:mm:ss,SSSS</timestampPattern>
<maximumMessageSize>8192</maximumMessageSize>
<!-- This are static fields -->
<additionalFields>fieldName1=fieldValue1,fieldName2=fieldValue2</additionalFields>
<!-- This are fields using MDC -->
<mdcFields>mdcField1,mdcField2</mdcFields>
<dynamicMdcFields>mdc.*,(mdc|MDC)fields</dynamicMdcFields>
<includeFullMdc>true</includeFullMdc>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
</appender>
<root level="DEBUG">
<appender-ref ref="gelf" />
</root>
</configuration>
+2
source to share