Log4j Example Properties File

The following is an example Log4j properties file for logging in different ways. By changing the line:

log4j.rootLogger=DEBUG,dailyByHour

One can vary the level of logging, and how the logging occurs. The properties file below supports general logging (logfile), rotating log files (rolling), daily by hour (dailyByHour), and daily by minute (dailyByMinute). To use log4j, be sure to set the property LOGGER_TYPE=LOG4J in the engine configuration, and place this properties file into your classpath. For additional details on log4j refer to Apache Log4j.

The sample shown can be downloaded here: log4j.properties

Sample Log4j Properties File

#
# Set root logger level (DEBUG, INFO, WARN, FATAL) and define logging appenders
#

log4j.rootLogger=DEBUG,dailyByHour
# stdout is set to be a ConsoleAppender
# stdout uses PatternLayout
# [date] [Priority] [class name] : [message]
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %-5p %M: %m%n

# logfile is set to be a RollingFileAppender. Keep 10 backup files before rotating
log4j.appender.rolling=org.apache.log4j.RollingFileAppender
log4j.appender.rolling.File=rollinglogfile.log
log4j.appender.rolling.MaxFileSize=50MB
log4j.appender.rolling.MaxBackupIndex=10
log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
log4j.appender.rolling.layout.ConversionPattern=%d{ISO8601} %-5p %30.40c{2} : %m%n

# logfile is set to be a FileAppender.
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=logfile.log
log4j.appender.file.append=false
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %-5p %30.40c{2} : %m%n

# logfile is set to be a DailyFileAppender - by minute
log4j.appender.dailyByMinute=org.apache.log4j.DailyRollingFileAppender
log4j.appender.dailyByMinute.File=logfile.log
log4j.appender.dailyByMinute.append=false
log4j.appender.dailyByMinute.DatePattern='.'yyyy-MM-dd-HH-mm
log4j.appender.dailyByMinute.layout=org.apache.log4j.PatternLayout
log4j.appender.dailyByMinute.layout.ConversionPattern=%d{ISO8601} %-5p %30.40c{2} : %m%n

# logfile is set to be a DailyFileAppender - by hour
log4j.appender.dailyByHour=org.apache.log4j.DailyRollingFileAppender
log4j.appender.dailyByHour.File=logfile.log
log4j.appender.dailyByHour.append=false
log4j.appender.dailyByHour.DatePattern='.'yyyy-MM-dd-HH
log4j.appender.dailyByHour.layout=org.apache.log4j.PatternLayout
log4j.appender.dailyByHour.layout.ConversionPattern=%d{ISO8601} %-5p #30.40c{2} : %m%n