Logback.xml Configurations for Java Applications – ELK

1] logback.xml configurations

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

<configuration>

<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 –>

localhost:4560

</destination>

<!– encoder is required –>

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

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

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

<fieldNames>

<logger>logger</logger>

<thread>thread</thread>

<message>msgTxt</message>

<tags>marker</tags>

</fieldNames>

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

<defaultMask>****</defaultMask>

<paths>clientId,msisdn</paths>

</jsonGeneratorDecorator> –>

</encoder>

</appender>

<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). –>

<queueSize>999</queueSize>

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

<neverBlock>true</neverBlock>

<!– 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

–>

<maxFlushTime>10000</maxFlushTime>

<appender-ref ref=”LOGSTASH_ASYNC” />

</appender>

<!– All the logger definitions–>

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

<appender-ref ref=”LOGSTASH” />

</logger>

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

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

<Pattern>

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

</Pattern>

</layout>

</appender>

 

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

<file>/var/log/bridging.log</file>

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

<fileNamePattern>logs/archived/app.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>

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

<maxFileSize>10MB</maxFileSize>

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

<totalSizeCap>20GB</totalSizeCap>

<!– 30 days to keep –>

<maxHistory>30</maxHistory>

</rollingPolicy>

<encoder>

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

</encoder>

</appender>

<root level=”INFO”>

<appender-ref ref=”LOGSTASH” />

<appender-ref ref=”STDOUT” />

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

</root>

</configuration>

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