我在日志文件中从org.apache.axiom和org.apache.axis2等软件包中收到了不需要的日志消息,例如。我刚刚将我的网络应用程序从log4j切换到了logback。我的tomcat服务器仍然配置为使用log4j。谁能教育我为什么?这些消息来自Tomcat吗?任何帮助将不胜感激!
以下是相关代码:
的web.xml
<web-app .....>
<listener>
<listener-class>ch.qos.logback.ext.spring.web.LogbackConfigListener</listener-class>
<listener>
<context-param>
<param-name>logbackConfigLocation</param-name>
<param-value>file:/opt/myapp/logback-server.xml</param-value>
</context-param>
<context-param>
<param-name>logbackExposeWebAppRoot</param-name>
<param-value>false</param-value>
</context-param>
<!-- Other Spring configuration -->
<web-app>
的logback-server.xml中
<configuration>
<appender name="MAIN" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/usr/local/logs/server.log</file>
<append>true</append>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter>
<level>DEBUG</level>
</filter>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} | %p | %c %M | %m%n
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/usr/local/logs/server.log.%d</fileNamePattern>
<appender>
<appender name="TRACE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/usr/local/logs/server-trace.log</file>
<append>true</append>
<filter class="ch.qos.logback.classic.filter.LevelFilter>
<level>TRACE</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} | %p | %c %M | %m%n
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/usr/local/logs/server-trace.log.%d</fileNamePattern>
<appender>
<root level="DEBUG">
<appender-ref ref="MAIN"/>
<appender-ref ref="TRACE"/>
</root>
</configuration>
答案 0 :(得分:0)
原来这是我的误解。
这种情况正在发生,因为我的根记录器的级别是DEBUG,因此文件中未指定的所有其他包都以DEBUG级别及更高级别记录。将根级别定义更改为:
<root level="WARN">
<appender-ref ref="MAIN"/>
<appender-ref ref="TRACE"/>
</root>