我有一个在 Tomcat 7.0.2 上运行并使用 log4j 进行日志记录的应用程序。在 tomcat 启动后不久,catalina.out 中出现以下消息:
INFO: Initializing log4j from [file:///export0/home/tomcat/appconf/log4j.xml]
log4j:WARN Unrecognized element rollingPolicy
log4j:WARN Please set a rolling policy for the RollingFileAppender named 'PERFFILE'
log4j:WARN Unrecognized element rollingPolicy
log4j:WARN Please set a rolling policy for the RollingFileAppender named 'FILE'
当我的实际日志消息应该打印时,我看到以下内容:
log4j:ERROR No output stream or file set for the appender named [FILE].
log4j:ERROR No output stream or file set for the appender named [PERFFILE].
这两个附加程序定义如下:
<appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="Append" value="true" />
<param name="File" value="${catalina.base}/logs/server.log" />
<rollingPolicy class="com.myapp.logging.AgingTimeBasedRollingFilePolicy">
<param name="fileNamePattern" value="${catalina.base}/logs/archive/server.%d{yyyy-MM-dd}.log.gz" />
<param name="keepFilesForDays" value="30" />
</rollingPolicy>
<layout class="com.myapp.logging.jboss.WebappAwarePattern">
<param name="ConversionPattern" value="%d{ISO8601}{${server.localTimezone}} %p [%X{webapp}:%c{2}] %m%n" />
</layout>
</appender>
<appender name="PERFFILE" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="Append" value="true" />
<param name="File" value="${catalina.base}/logs/performance.log" />
<rollingPolicy class="com.myapp.logging.AgingTimeBasedRollingFilePolicy">
<param name="fileNamePattern" value="${catalina.base}/logs/archive/performance.%d{yyyy-MM-dd}.log.gz" />
<param name="keepFilesForDays" value="30" />
</rollingPolicy>
<layout class="com.myapp.logging.jboss.WebappAwarePattern">
<param name="ConversionPattern" value="%d{ISO8601}{${server.localTimezone}} %p [%X{webapp}:%c{2}] %throwable{0} %m%n" />
</layout>
</appender>
我一直很难弄清楚为什么会发生此错误但没有结果(可能我的 log4j.xml 无法正确解析)
因此,任何为什么会发生这种情况的想法都将受到高度赞赏。
提前致谢!