log4j2.properties example
By:Roy.LiuLast updated:2019-08-11
A simple log4j2.properties example, just for self-reference
P.S Tested with Log4j 2.11.2
src/resources/log4j2.properties
status = warn appender.console.type = Console appender.console.name = LogToConsole appender.console.layout.type = PatternLayout appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n #appender.file.type = File #appender.file.name = LogToFile #appender.file.fileName=logs/app.log #appender.file.layout.type=PatternLayout #appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n # Rotate log file appender.rolling.type = RollingFile appender.rolling.name = LogToRollingFile appender.rolling.fileName = logs/app.log appender.rolling.filePattern = logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz appender.rolling.layout.type = PatternLayout appender.rolling.layout.pattern = %d %p %C{1.} [%t] %m%n appender.rolling.policies.type = Policies appender.rolling.policies.time.type = TimeBasedTriggeringPolicy appender.rolling.policies.size.type = SizeBasedTriggeringPolicy appender.rolling.policies.size.size=10MB appender.rolling.strategy.type = DefaultRolloverStrategy appender.rolling.strategy.max = 10 # Log to console and rolling file logger.app.name = com.mkyong logger.app.level = debug logger.app.additivity = false logger.app.appenderRef.rolling.ref = LogToRollingFile logger.app.appenderRef.console.ref = LogToConsole rootLogger.level = info rootLogger.appenderRef.stdout.ref = LogToConsole
From:一号门
Previous:log4j2.yml example
COMMENTS