简体   繁体   English

Logback:在特定的附加程序上启用 class 并在其他附加程序上禁用它

[英]Logback : enable class on specific appender et disable it on the others

A specific class from a dependency produces too much logs, so I'm trying to store them in a specific file to avoid pollution of the other ones.来自依赖项的特定 class 会产生太多日志,因此我尝试将它们存储在特定文件中以避免污染其他文件。

here's my logback-spring.xml file:这是我的 logback-spring.xml 文件:

<configuration debug="true">

<!-- appenders declaration --> 

    <logger
        name="org.apache.james.protocols.netty.BasicChannelUpstreamHandler"
        level="INFO">
        <appender-ref ref="FileConnections" />
    </logger>


    <root level="DEBUG">
        <appender-ref ref="FileInf" /> <!-- ThresholdFilter Info -->
        <appender-ref ref="FileErr" /> <!-- ThresholdFilter Error -->
        <appender-ref ref="FileTra" /> <!-- ThresholdFilter Trace -->
        <appender-ref ref="JsonInf" /> <!-- Json formater -->
        <appender-ref ref="STDOUT" />  <!-- Console output -->
    </root>


</configuration> 

This code does redirect all the BasicChannelUpstreamHandler logs to my FileConnections appender but there is still logs fromm this class in other appenders.此代码确实将所有 BasicChannelUpstreamHandler 日志重定向到我的 FileConnections 附加程序,但在其他附加程序中仍有来自此 class 的日志。

Is there a way to disable BasicChannelUpstreamHandler logs on all the other appenders?有没有办法在所有其他附加程序上禁用 BasicChannelUpstreamHandler 日志?

You need to set the additivity flag to false as shown below.您需要将可加性标志设置为false ,如下所示。

<logger name="org.apache.james.protocols.netty.BasicChannelUpstreamH‌​andler" level="INFO" additivity="false"> 
    <appender-ref ref="FileConnections" /> 
</logger>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM