log4j2 RollingFileAppender覆盖当前日志文件

时间:2019-06-25 15:53:02

标签: java log4j log4j2

我正在使用下面的log4j2.properties。每次我的代码运行时,test.log文件都会被覆盖。我需要每次运行都将其追加到日志,直到达到5KB或更改日期为止。

status = error
name = PropertiesConfig

property.filename = C:\\Logs\\test.log

filters = threshold

filter.threshold.type = ThresholdFilter
filter.threshold.level = trace

appenders = rolling

appender.rolling.type = RollingFile
appender.rolling.name = RollingFile
appender.rolling.fileName = ${filename}
appender.rolling.filePattern = test-%d{MM-dd-yy-HH-mm-ss}-%i.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L -     %m%n
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=5KB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 7

loggers = rolling


logger.rolling.name = com.logtest
logger.rolling.level = debug
logger.rolling.additivity = false
logger.rolling.appenderRef.rolling.ref = RollingFile

0 个答案:

没有答案