记录器的初始化不成功

时间:2012-05-07 10:00:27

标签: log4j

我在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配置中设置属性存在一些问题。有什么帮助吗?

感谢。

1 个答案:

答案 0 :(得分:0)

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