log4j2.properties配置内容样例
时间: 2023-09-14 08:14:30 浏览: 133
# 设置日志输出级别为DEBUG
log4j2.rootLogger.level = DEBUG
# 输出到控制台
log4j2.appender.console.type = Console
log4j2.appender.console.name = consoleAppender
log4j2.appender.console.target = SYSTEM_OUT
log4j2.appender.console.layout.type = PatternLayout
log4j2.appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
# 输出到文件
log4j2.appender.file.type = RollingFile
log4j2.appender.file.name = fileAppender
log4j2.appender.file.fileName = ./logs/app.log
log4j2.appender.file.filePattern = ./logs/app-%d{yyyy-MM-dd}.log
log4j2.appender.file.layout.type = PatternLayout
log4j2.appender.file.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
log4j2.appender.file.policies.type = Policies
log4j2.appender.file.policies.time.type = TimeBasedTriggeringPolicy
log4j2.appender.file.policies.time.interval = 1
log4j2.appender.file.policies.time.modulate = true
# 设置日志输出级别为INFO
log4j2.logger.com.example = INFO
log4j2.additivity.com.example = false
log4j2.appender.console.filter.threshold.type = ThresholdFilter
log4j2.appender.console.filter.threshold.level = INFO
log4j2.appender.file.filter.threshold.type = ThresholdFilter
log4j2.appender.file.filter.threshold.level = INFO
阅读全文