<div dir="ltr"><div>I'm maintaining a Java application that's using logback1.2.2. Someone who isn't around anymore set up the logback configuration, and I'm having some trouble understanding it.</div><div><br></div><div>I am trying to add a filter. The behavior I'm seeing is that the filter works fine on lines that are logged at the INFO level, but the filter is not filtering lines that are logged at the DEBUG level. (So the INFO lines are removed correctly, but the DEBUG lines are still being logged.)</div><div><br></div><div>Furthermore, I'm realizing that I don't actually understand why any of the DEBUG logging (regardless of the filter) is happening at all. DEBUG logging is working, and I want DEBUG logging to be working, but I'm not understanding why it's working. The reason I was thinking that it wouldn't be working is that the logback.xml adds the file appender to a root node that has level=INFO, so I was expecting to only see INFO logging and not DEBUG logging.</div><div><br></div><div>Here is the logback.xml (including the filter that I added to both of the appenders)...<br><span style="font-family:monospace"><configuration debug="true"><br>    <logger name="com.mycompany" level="debug"/><br>    <logger name="com.mycompany.app.server.config.AccessLogHandler" level="INFO" /><br>    <logger name="org.hibernate" level="info"/><br>    <logger name="org.springframework" level="info"/><br>    <logger name="org.apache" level="info"/><br><br>    <jmxConfigurator /><br>    <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/><br><br>    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"><br>        <encoder><br>            <pattern>%date \(%thread\) %-5level [%logger{40}] %message%n</pattern><br>        </encoder><br>        <filter class="ch.qos.logback.core.filter.EvaluatorFilter">      <br>          <evaluator><br>            <expression>return message.contains("UserInfoEntry");</expression><br>          </evaluator><br>          <OnMismatch>NEUTRAL</OnMismatch><br>          <OnMatch>DENY</OnMatch><br>        </filter><br>    </appender><br><br>    <property name="LOG_PATH" value="var/log"/><br>    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"><br>        <filter class="ch.qos.logback.core.filter.EvaluatorFilter">      <br>          <evaluator><br>            <expression>return message.contains("UserInfoEntry");</expression><br>          </evaluator><br>          <OnMismatch>NEUTRAL</OnMismatch><br>          <OnMatch>DENY</OnMatch><br>        </filter><br><br>        <file>${LOG_PATH}/app.log</file><br>        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><br>            <!-- daily rollover. Make sure the path matches the one in the file element or else<br>             the rollover logs are placed in the working directory. --><br>            <fileNamePattern>${LOG_PATH}/app_%d{yyyy-MM-dd}.%i.log</fileNamePattern><br><br>            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><br>                <maxFileSize>5MB</maxFileSize><br>            </timeBasedFileNamingAndTriggeringPolicy><br>            <!-- keep 30 days' worth of history --><br>            <maxHistory>30</maxHistory><br>        </rollingPolicy><br><br>        <encoder><br>            <charset>UTF-8</charset><br>            <pattern>%date [%thread] %-5level %logger{36} %X - %msg%n</pattern><br>        </encoder><br>    </appender><br><br>    <root level="INFO"><br>        <appender-ref ref="FILE"/><br>    </root><br></configuration></span><br><br></div><div>Here is the output from logback (since i have debug=true on)...</div><div><span style="font-family:monospace">20:50:55,109 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]<br>20:50:55,109 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]<br>20:50:55,109 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/opt/app/app-server-4.3.1-SNAPSHOT/etc/logback.xml]<br>20:50:55,224 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.mycompany] to DEBUG<br>20:50:55,224 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.security] to INFO<br>20:50:55,224 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.mycompany.app.server.config.AccessLogHandler] to INFO<br>20:50:55,224 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate] to INFO<br>20:50:55,224 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework] to INFO<br>20:50:55,224 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.zaxxer.hikari.pool.PoolBase] to WARN<br>20:50:55,225 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.aop.framework.CglibAopProxy] to ERROR<br>20:50:55,225 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.eclipse.jetty.util.log] to WARN<br>20:50:55,225 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.netflix.hystrix] to WARN<br>20:50:55,225 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache] to INFO<br>20:50:55,225 |-INFO in ch.qos.logback.classic.joran.action.JMXConfiguratorAction - begin<br>20:50:55,291 |-INFO in ch.qos.logback.classic.joran.action.LoggerContextListenerAction - Adding LoggerContextListener of type [ch.qos.logback.classic.jul.LevelChangePropagator] to the object stack<br>20:50:55,293 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5e853265 - Propagating DEBUG level on Logger[ROOT] onto the JUL framework<br>20:50:55,293 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5e853265 - Propagating WARN level on Logger[com.netflix.hystrix] onto the JUL framework<br>20:50:55,293 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5e853265 - Propagating DEBUG level on Logger[com.mycompany] onto the JUL framework<br>20:50:55,293 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5e853265 - Propagating INFO level on Logger[com.mycompany.app.server.config.AccessLogHandler] onto the JUL framework<br>20:50:55,293 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5e853265 - Propagating WARN level on Logger[com.zaxxer.hikari.pool.PoolBase] onto the JUL framework<br>20:50:55,293 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5e853265 - Propagating INFO level on Logger[org.apache] onto the JUL framework<br>20:50:55,294 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5e853265 - Propagating WARN level on Logger[org.eclipse.jetty.util.log] onto the JUL framework<br>20:50:55,294 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5e853265 - Propagating INFO level on Logger[org.hibernate] onto the JUL framework<br>20:50:55,294 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5e853265 - Propagating INFO level on Logger[org.springframework] onto the JUL framework<br>20:50:55,294 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5e853265 - Propagating ERROR level on Logger[org.springframework.aop.framework.CglibAopProxy] onto the JUL framework<br>20:50:55,294 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5e853265 - Propagating INFO level on Logger[org.springframework.security] onto the JUL framework<br>20:50:55,294 |-INFO in ch.qos.logback.classic.joran.action.LoggerContextListenerAction - Starting LoggerContextListener<br>20:50:55,294 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]<br>20:50:55,298 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]<br>20:50:55,303 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property<br>20:50:55,336 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.boolex.JaninoEventEvaluator] for [evaluator] property<br>20:50:55,582 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]<br>20:50:55,585 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]<br>20:50:55,586 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.boolex.JaninoEventEvaluator] for [evaluator] property<br>20:50:55,603 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@419c5f1a - The date pattern is 'yyyy-MM-dd' from file name pattern 'var/log/app_%d{yyyy-MM-dd}.%i.log'.<br>20:50:55,603 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@419c5f1a - Roll-over at midnight.<br>20:50:55,607 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@419c5f1a - Setting initial period to Thu Sep 19 20:50:54 UTC 2019<br>20:50:55,607 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@419c5f1a - SizeAndTimeBasedFNATP is deprecated. Use SizeAndTimeBasedRollingPolicy instead<br>20:50:55,608 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@419c5f1a - For more information see <a href="http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy">http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy</a><br>20:50:55,611 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property<br>20:50:55,613 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Active log file name: var/log/app.log<br>20:50:55,613 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - File property is set to [var/log/app.log]<br>20:50:55,615 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO<br>20:50:55,615 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@5e853265 - Propagating INFO level on Logger[ROOT] onto the JUL framework<br>20:50:55,615 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT]<br>20:50:55,622 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.<br>20:50:55,622 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@96def03 - Registering current configuration as safe fallback point</span></div><div><br></div><div> <br></div><div>Can anyone help determine what's going on?</div><div><br></div><div>The two questions are:</div><div>1) What is it that's causing the DEBUG logging to be on? (I like that it's on, but don't understand why it's on.)</div><div>2) Why is the filter filtering INFO lines but not filtering DEBUG lines? (I want it filtering DEBUG lines.)</div><div><br></div><div><br></div><div>Thanks,</div><div>Mike<br></div><div><br> </div></div>