2

我在 tomcat 6.0.35 中使用下面提到的 log4j.properties 文件

log4j.appender.request=org.apache.log4j.rolling.RollingFileAppender
log4j.appender.request.Append=true
log4j.fileName=logs/test
log4j.appender.request.File=${log4j.fileName}.log
log4j.appender.request.RollingPolicy=org.apache.log4j.rolling.FixedWindowRollingPolicy
log4j.appender.request.RollingPolicy.FileNamePattern=${log4j.fileName}.%i.log.zip
log4j.appender.request.RollingPolicy.MinIndex=1
log4j.appender.request.RollingPolicy.MaxIndex=10

log4j.appender.request.TriggeringPolicy=org.apache.log4j.rolling.SizeBasedTriggeringPolicy
log4j.appender.request.TriggeringPolicy.MaxFileSize=10485760

log4j.appender.request.layout=org.apache.log4j.PatternLayout
log4j.appender.request.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

log4j.rootLogger=info, request

但我收到以下消息

log4j:WARN Failed to set property [rollingPolicy] to value "org.apache.log4j.rolling.FixedWindowRollingPolicy".
log4j:WARN Failed to set property [triggeringPolicy] to value "org.apache.log4j.rolling.SizeBasedTriggeringPolicy".
log4j:WARN Please set a rolling policy for the RollingFileAppender named 'request'
log4j:WARN Failed to set property [rollingPolicy] to value "org.apache.log4j.rolling.FixedWindowRollingPolicy".
log4j:WARN Failed to set property [triggeringPolicy] to value "org.apache.log4j.rolling.SizeBasedTriggeringPolicy".
log4j:WARN Please set a rolling policy for the RollingFileAppender named 'request'
log4j:ERROR No output stream or file set for the appender named [request].

在 log4j 配置中设置属性存在一些问题。有什么帮助吗?

谢谢。

4

1 回答 1

0

我今天使用 apache-log4j-extras1.1.jar 遇到了这个问题。经过一段时间的摔跤,我发现我的 log4j.jar 版本是 1.2.14 是问题所在。我更新到 1.2.17 并解决了我的问题。确保它位于您的 tomcat(或您的应用程序)中的任何其他 log4j 之前。

于 2012-06-15T13:02:02.317 回答