在 log4j 中配置 RollingFileAppender
我正在开发一组Web服务,我们希望有一个每日轮换的日志。
我试图从log4j extras伴侣那里获得工作,因为文档表明这最适合生产环境。org.apache.log4j.rolling.RollingFileAppender
我在类路径上有主log4J库()和log4j附加库()。log4j-1.2.15.jar
apache-log4j-extras-1.1.jar
我在文件中为追加器提供了以下配置:log4j.properties
### SOAP Request Appender
log4j.appender.request=org.apache.log4j.rolling.RollingFileAppender
log4j.appender.request.File=SOAPmessages.log
log4j.appender.request.RollingPolicy=org.apache.log4j.rolling.TimeBasedRollingPolicy
log4j.appender.request.RollingPolicy.ActiveFileName =SOAPmessages-%d.log
log4j.appender.request.RollingPolicy.FileNamePattern=SOAPmessages-%d.log.zip
log4j.appender.request.layout = org.apache.log4j.PatternLayout
log4j.appender.request.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
但是,当我在调试模式下使用log4j启动Web服务时,我收到以下错误消息:
log4j: Parsing appender named "request".
log4j: Parsing layout options for "request".
log4j: Setting property [conversionPattern] to [%d{ABSOLUTE} %5p %c{1}:%L - %m%n].
log4j: End of parsing for "request".
log4j: Setting property [file] to [/logs/SOAPmessages.log].
log4j:WARN Failed to set property [rollingPolicy] to value "org.apache.log4j.rolling.TimeBasedRollingPolicy".
log4j:WARN Please set a rolling policy for the RollingFileAppender named 'request'
log4j: Parsed "request" options.
我发现有关如何配置此附加器的文档有点稀疏,因此任何人都可以帮助我修复我的配置吗?
编辑0:添加了调试模式输出,而不仅仅是标准警告