Appender with filter "ERROR" and logger with level "INFO" print DEBUG log. How to avoid it?

41 Views Asked by At

There is a snippet from my logback configuration:

    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">        
        <param name="Target" value="System.out"/>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERROR</level> 
        </filter>    
        <encoder>
            <pattern>%date %level [%thread] %logger{50} - %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="router" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!--  Remove from comment the following filter if you want to deny certain expression from being logged. Note - the stringToMatch you insert is case sensitive -->
        <!-- filter class="com.allot.smp.util.logback.StringMatchFilter">
            <stringToMatch></stringToMatch>
        </filter -->        
        <file>/path/to/file.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <maxIndex>10</maxIndex>
            <FileNamePattern>/path/to/file.log.%i</FileNamePattern>
        </rollingPolicy>
        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>50MB</MaxFileSize>
        </triggeringPolicy>
        <encoder>
            <Pattern>%date %level [%thread] %logger{50} [SID:%X{SID}, IP:%X{IP}]- %msg%n</Pattern>
        </encoder>
    </appender>

    <logger name="org.apache">
        <level value="INFO" />
        <appender-ref ref="router" />
    </logger>

    <root>
        <appender-ref ref="stdout"/>
    </root>

I expect that from all objects in package org.apache I will see logs:

  • in file /path/to/file.log logs of level INFO and higher.
  • in stdout logs of level ERROR and higher.

But in stdout I see logs like this:

14:56:22.968 [main] DEBUG org.apache.commons.configuration.PropertiesConfiguration - Base path set to file:///path/to/some/properties.default
14:56:22.987 [main] DEBUG org.apache.commons.configuration.PropertiesConfiguration - FileName set to properties.default

Why it happens and how to solve it?

UPD1

As I can see it happens on the process start. I can't find such issues at runtime. Could it be because first logs are done before logback initialized and loaded configurations?

0

There are 0 best solutions below