[logback-dev] logback console display not honoring threshold filter

Todd Prickett toddprickett at outlook.com
Thu Jul 23 15:34:58 CEST 2015


I have a logback.xml file containing the following:

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

<appender name="debugfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>debugFile.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>debugFile.%d{yyyy-MM-dd}.log</fileNamePattern>
        <MaxHistory>30</MaxHistory>
    </rollingPolicy>
    <encoder>
        <pattern>%date %-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
    </encoder>
</appender>

<appender name="infofile" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>infoFile.log</file>
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
        <level>INFO</level>
    </filter>
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
        <fileNamePattern>infoFile_%i.log</fileNamePattern>
        <minIndex>1</minIndex>
        <maxIndex>3</maxIndex>
    </rollingPolicy>
    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <maxFileSize>1MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
        <pattern>%date %-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
    </encoder>
</appender>

<appender name="warnfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>infoFile.log</file>
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
        <level>WARN</level>
    </filter>
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
        <fileNamePattern>warnFile_%i.log</fileNamePattern>
        <minIndex>1</minIndex>
        <maxIndex>3</maxIndex>
    </rollingPolicy>
    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <maxFileSize>1MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
        <pattern>%date %-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
    </encoder>
</appender>


<root>
    <appender-ref ref="console"/>
    <appender-ref ref="debugfile"/>
    <appender-ref ref="infofile"/>
<appender-ref ref="warnfile"/>
</root>


I want it to only show me INFO level logs or greater. So, I added the ThresholdFilter and set its level to INFO. Doing this worked for the RollingFileAppender (where one includes INFO and greater and the other includes DEBUG and greater).This didn't make a difference as the console statements continue to include DEBUG level statements. Can anyone tell me why?


 		 	   		  


More information about the logback-dev mailing list