Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logback per-logger configuration is not working

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?

like image 676
smirnoff Avatar asked Dec 22 '22 04:12

smirnoff


1 Answers

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.

like image 72
smirnoff Avatar answered Feb 22 '23 11:02

smirnoff