Logback.xml Configurations for Java Applications – ELK

1] logback.xml configurations

<?xml version=”1.0″ encoding=”UTF-8″?>


<property scope=”context” name=”tag” value=”dmtool-app-services” />

<property scope=”context” name=”service_name” value=”dmtool-app-services” />

<property scope=”context” name=”host” value=”${service.host.name}” />

<property scope=”context” name=”service_port” value=”5555″ />

<property scope=”context” name=”service_instanceId” value=”1″ />

<appender name=”LOGSTASH_ASYNC” class=”net.logstash.logback.appender.LogstashTcpSocketAppender”>

<destination> <!– can put multiple destination separated by comma –>



<!– encoder is required –>

<encoder class=”net.logstash.logback.encoder.LogstashEncoder”>

<!– This will generate more information might help in debug purpose –>

<!– <includeCallerData>true</includeCallerData>–>







<!–<jsonGeneratorDecorator class=”net.logstash.logback.mask.MaskingJsonGeneratorDecorator”>



</jsonGeneratorDecorator> –>



<appender name=”LOGSTASH” class=”ch.qos.logback.classic.AsyncAppender”>

<!– Max queue size of logs which is waiting to be sent (When it reach to the max size, the log will be disappeared). –>


<!– Never block when the queue becomes full. –>


<!– The default maximum queue flush time allowed during appender stop.

If the worker takes longer than this time it will exit, discarding any remaining items in the queue.

10000 millis



<appender-ref ref=”LOGSTASH_ASYNC” />


<!– All the logger definitions–>

<logger name=”com.ericsson” level=”INFO” additivity=”false”>

<appender-ref ref=”LOGSTASH” />


<appender name=”STDOUT” class=”ch.qos.logback.core.ConsoleAppender” additivity=”false”>

<layout class=”ch.qos.logback.classic.PatternLayout”>


%d{yyyy-MM-dd HH:mm:ss} [%15.15thread] %-5level %logger{0} – %msg%n





<appender name=”FILE_APPENDER” class=”ch.qos.logback.core.rolling.RollingFileAppender”>


<rollingPolicy class=”ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy”>


<!– each archived file, size max 10MB –>


<!– total size of all archive files, if total size > 20GB, it will delete old archived file –>


<!– 30 days to keep –>




<pattern><![CDATA[%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %marker %-5level %logger{15}#%line %X{req.requestURI} %msg%n]]></pattern>



<root level=”INFO”>

<appender-ref ref=”LOGSTASH” />

<appender-ref ref=”STDOUT” />

<!– <appender-ref ref=”FILE_APPENDER” /> –>



About ashokabhat

I am a C,C ,JAVA,Adobe Flex,.NET Programmer Currently working as a Software Developer
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s