简体   繁体   中英

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.

here's my logback-spring.xml file:

<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.

Is there a way to disable BasicChannelUpstreamHandler logs on all the other appenders?

You need to set the additivity flag to false as shown below.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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