[WSO2 CARBON] Managing Logs in WSO2 Servers

When working with WSO2 servers managing logs is essential. Managing logs in WSO2 servers on a production environment would be useful since logs can grow on eating precious disk space eventually affecting the server performance. So how can you manage them without sacrifing disk space? Using the log4j.properties shipped with WSO2 Carbon we can manage this task.

Go to “CARBON_HOME/repository/conf/log4j.properties” and you will find the following configuration;

# Appender config to CARBON_TRACE_LOGFILE
log4j.appender.CARBON_TRACE_LOGFILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.CARBON_TRACE_LOGFILE.File=${carbon.home}/repository/logs/${instance.log}/wso2carbon-trace-messages${instance.log}.log
log4j.appender.CARBON_TRACE_LOGFILE.Append=true
log4j.appender.CARBON_TRACE_LOGFILE.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout
log4j.appender.CARBON_TRACE_LOGFILE.layout.ConversionPattern=[%d] %P%5p {%c} - %x %m %n
log4j.appender.CARBON_TRACE_LOGFILE.layout.TenantPattern=%U%@%D [%T] [%S]
log4j.appender.CARBON_TRACE_LOGFILE.threshold=TRACE

Add/Modify these configuration as follow;

log4j.appender.CARBON_LOGFILE=org.apache.log4j.RollingFileAppendersection.
log4j.appender.CARBON_LOGFILE.MaxFileSize=20MB
log4j.appender.CARBON_LOGFILE.MaxBackupIndex=1000

This will ensure total 20MB * 1000 will be used. i. e first 1000 entries of 20MB chunks will be retained

managing logs in WSO2 servers can be achieved quite easily by following the above steps which will make maintenance of these servers a hassle free task.

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.