Rotating Datameer Logs

Rotating Datameer Logs

You can move and compress logs to the /var/log/backup directory for archiving each day.

To do this, edit the das/conf/log4j-production.properties. 

The important lines for configuring where logs are sent are in the RollingFileAppender appenders for the conductor.log (log4j.appender.file) and for the useraction.log (log4j.appender.useraction).

The default setting rolls the file when it reached a certain size. To change the size for your daily rolling log you can use log4js DailyRollingFileAppender.

Using conductor log as an example, here is the default definition:

log4j.appender.file=org.apache.log4j.RollingFileAppender 
log4j.appender.file.layout=datameer.dap.conductor.util.logging.CustomLog4jPatternLayout 
log4j.appender.file.layout.ConversionPattern=[%u] %5p [%d{yyyy-MM-dd HH:mm:ss}] (%F:%L) - %m%n 
log4j.appender.file.File=logs/conductor.log 
log4j.appender.file.MaxFileSize=1000KB 
log4j.appender.file.MaxBackupIndex=10 

This could be changed to:

log4j.appender.file=org.apache.log4j.DailyRollingFileAppender 
log4j.appender.file.layout=datameer.dap.conductor.util.logging.CustomLog4jPatternLayout 
log4j.appender.file.layout.ConversionPattern=[%u] %5p [%d{yyyy-MM-dd HH:mm:ss}] (%F:%L) - %m%n 
log4j.appender.file.File=logs/conductor.log 
log4j.appender.file.DatePattern='.'yyyy-MM-dd 

You receive the roll logs/conductor.log at midnight to a file you specify. (example: logs/conductor.log.2011-12-23.gz)

This allows you to compress files and move them at your convenience.

When switching from RollingFileAppender to DailyRollingFileAppender, log4j looses the ability to cleanup old log files.

See log4j for more information.