每个记录器的 logback 配置不起作用
我正在尝试禁用 logback-test.xml 中所有外部库的日志输出。不知怎的,它并不像广告中那样起作用,我不明白为什么。
这是我的 logback-test.xml 的内容:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<!-- Turn off third party chatter -->
<logger name="httpclient.wire" level="OFF" />
<logger name="o.s" level="OFF"/>
<logger name="org.spring" level="OFF"/>
<logger name="org.apache" level="OFF"/>
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
我明确关闭了 org.spring 记录器,但我仍然看到来自 Spring 的所有调试输出。但是,如果我在元素中指定不同的级别,它就会起作用。有什么想法为什么会发生吗?
I'm trying to disable log output from all external libraries in logback-test.xml. Somehow it does not work as advertised, and I don't understand why.
This is the contents of my logback-test.xml:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<!-- Turn off third party chatter -->
<logger name="httpclient.wire" level="OFF" />
<logger name="o.s" level="OFF"/>
<logger name="org.spring" level="OFF"/>
<logger name="org.apache" level="OFF"/>
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
I explicitly turned off org.spring logger, yet I still see all debug output from Spring. However, if I specify different level in element, it works. Any ideas why it happens?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是:知道您的记录器名称!所有 Spring 记录器都以 org.springframework 开头,而不是 org.spring。修复名称后,一切正常,即使类路径中存在公共日志记录也是如此。
And the answer is: know your logger name! All Spring loggers start with org.springframework, not org.spring. After I fixed the name, everything works, even with commons-logging present in the classpath.