Graylog Integration with Logback


To demonstrate the steps to integrate graylog with logback logging implementation


1. An exciting application with logback enables logging
2. JDK1.5(Specific fix)/JDK 1.6+
3. GELF dependency for Logback

 Name Logback dependency Compatible JDK Status
 logback-gelf <dependency>
 JDK1.6/+ Worked



logback-gelf dependency is built on JDK1.6/+ and using some additional functions(copyOfRange() and copyOf()).

Add mentioned dependency into pom.xml(Web and enterprise package)



Appender for Graylog

You need to add following appender to integrate graylog in logback configuration.

For the respective values, please visit grayling user guide.

Property Name  Used for  
 useLoggerName  To log the logger name  true
 useThreadName  To log the thread name  true

For more details on properties, please click here


Root Loger and default appender

To feed the log into graylog server, set default root logger level and appender in logback.xml.

Default Root Logger



TCP supported Appender problem

Normal GELF appender uses TCP protocol and that makes synchronous call. Because of this behaviour, there will be minor/major performance impact on the application. Resultant of this, the response time will increased.

So, to overcome from this problem(Step-5), feed the log to graylog server asynchronously. So that there won’t be any impact on application performance.



Integrate ASYNC appender

Add below appender into logback.xml and set this as default appender for root logger.

ASYNC Appender Default Root Logger
 <appender name=”ASYNC” class=”ch.qos.logback.classic.AsyncAppender”><param name=”queueSize” value=”500″/>
<appender-ref ref=”GELF” />
 <root level=”INFO”><appender-ref ref=”ASYNC” />
Property Meaning
queueSize This is used to buffer the no of message events to log into graylog server. The default value for this is 256.



To disable the graylog Solution
<root level=”INFO”>
<!–<appender-ref ref=”ASYNC” />–>
1. Commen out the ASYNC Appender ref from root logger.
2. Remove this entry itself from root logger.



Below is pop up screen to search any log. Search is enable for any of the below parameter, to search based on application then enter facility/application name in highlighted area and hit “Run filter”.

image post 3

To search based on log message, search using Full message with ‘*’ as prefix. e.g. *PROVIDER_REQUEST

share or like this post

One thought on “Graylog Integration with Logback

  1. FranHancockq

    I see your website needs some unique articles. Writing manually is time consuming,
    but there is solution for this hard task. Just search for – Miftolo’s tools rewriter

Leave a Reply

Your email address will not be published. Required fields are marked *