gpt4 book ai didi

java - Log4j 配置(基于大小)不起作用

转载 作者:搜寻专家 更新时间:2023-11-01 03:40:45 25 4
gpt4 key购买 nike

我的应用程序在 Log4j 属性文件中完成了以下条目。基于大小的滚动不适用于此应用程序。文件不会在 5 MB 时翻转,应用程序会继续记录并以 GB 为单位进行记录。在一次运行中生成大约 6 MB 的日志。该应用程序每天运行多次。

有人可以帮助指出我哪里做错了吗?

# SampleApp configuration
log4j.category.com.ibm.hmel.hwmmphdya=INFO, SampleApp
log4j.additivity.com.ibm.hmel.hwmmphdya=false
log4j.appender.SampleApp =org.apache.log4j.rolling.RollingFileAppender
log4j.appender.SampleApp.File=S:/FIH/LOG/SAMPLE_APP_01/SAMPLE_APP_01.log
log4j.appender.SampleApp.layout=org.apache.log4j.PatternLayout
log4j.appender.SampleApp.layout.ConversionPattern=%-21d{dd-MMM-yyyy HH:mm:ss} [%t] %-5p %c %x - %m%n

log4j.appender.SampleApp.RollingPolicy=org.apache.log4j.rolling.FixedWindowRollingPolicy
log4j.appender.SampleApp.RollingPolicy.FileNamePattern=S:/HIF/LOG/SAMPLE_APP_01 /SAMPLE_APP_01.log.%i.zip
log4j.appender.SampleApp.RollingPolicy.MinIndex=1
log4j.appender.SampleApp.RollingPolicy.MaxIndex=10
log4j.appender.SampleApp.TriggeringPolicy=org.apache.log4j.rolling.SizeBasedTriggeringPolicy
log4j.appender.SampleApp.TriggeringPolicy.MaxFileSize=5242880

最佳答案

以下对我有用

log4j.rootLogger=TRACE, Roller

log4j.appender.Roller=org.apache.log4j.rolling.RollingFileAppender
log4j.appender.Roller.RollingPolicy=org.apache.log4j.rolling.FixedWindowRollingPolicy
log4j.appender.Roller.RollingPolicy.maxIndex=13
log4j.appender.Roller.TriggeringPolicy=org.apache.log4j.rolling.SizeBasedTriggeringPolicy
log4j.appender.Roller.TriggeringPolicy.MaxFileSize=26214400
log4j.appender.Roller.RollingPolicy.FileNamePattern=j_log_%i.log
log4j.appender.Roller.RollingPolicy.ActiveFileName=j_log_0.log
log4j.appender.Roller.layout=org.apache.log4j.PatternLayout
log4j.appender.Roller.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

关于java - Log4j 配置(基于大小)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15105694/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com