Log4j Example Properties File

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

rootLogger = info,RollingFile

One can vary the level of logging, and how the logging occurs. The properties file below supports general logging, rotating log files, daily by hour, and daily by minute. 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: log4j2.properties

Sample Log4j Properties File


#The level of internal Log4j events that should be logged to the console.
status=off

#name of the configuration
name=PropertiesConfig

#The minimum amount of time, in seconds, that must elapse before the file configuration is checked for changes.
monitorInterval=15

property.filename=logs/fluxEngine.log

# Define Appenders
appenders=rolling

# console is set to be a ConsoleAppender
# console uses PatternLayout
# [date] [Priority] [class name] : [message]
appender.console.type=Console
appender.console.name=STDOUT
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d{ISO8601} %-5p %t %M: %m%n

# logfile is set to be a daily RollingFileAppender. For hourly, change the file name patten with this yyyy-MM-dd-HH.
appender.rolling.type=RollingFile
appender.rolling.name = RollingFile
appender.rolling.fileName = ${filename}
appender.rolling.filePattern = logs/fluxEngine-%d{yyyy-MM-dd}-%i.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern=%d{ISO8601} %-5p %t %30.40c{2} : %m%n


# Policies for an appender
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size=50MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 10

# define loggers and level
loggers=rolling
logger.rolling.name=flux
logger.rolling.level=info
logger.rolling.appenderRef.rolling.ref=RollingFile

# define console as the logger
# loggers=console
# logger.console.name=flux
# logger.console.level=info


# define root logger
rootLogger = info,RollingFile