Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
410 views
in Technique[技术] by (71.8m points)

log4j - How can we set maximum number of log files in log4j2.properties ? And, what else can be improved?

I am using it in SpringBoot Application. It should bot create more than five files. But, it has no limit. Here is the code.

name=PropertiesConfig
property.filename=abc.log

# configuration to print on console
appender.console.type=Console
appender.console.name=STDOUT
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss} [%t] %C{1}:%L - %msg%n

# configuration to print into file
appender.rolling.type=RollingFile
appender.rolling.name=RollingFile
appender.rolling.fileName=${filename}
appender.rolling.filePattern=abc.%d{MM-dd-yyyy-HH-mm-ss}.log.gz
appender.rolling.layout.type=PatternLayout
appender.rolling.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss} [%t] %C{1}:%L - %msg%n
appender.rolling.policies.type=Policies
appender.rolling.policies.size.type=SizeBasedTriggeringPolicy
appender.rolling.policies.size.size=10MB
appender.rolling.strategy.type=DefaultRolloverStrategy
appender.rolling.strategy.max = 5



 
rootLogger.level=trace
rootLogger.appenderRef.stdout.ref=STDOUT
rootLogger.appenderRef.file.ref=RollingFile
question from:https://stackoverflow.com/questions/65839548/how-can-we-set-maximum-number-of-log-files-in-log4j2-properties-and-what-else

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...