[logback-user] How to disable logger output to one of its appenders

Joud Kassem joud.kassem79 at gmail.com
Tue Nov 30 15:35:45 CET 2021


Hi all,

I have an "org.geotools" logger with 2 appenders, each appender directs the
output to a different file. This is the default configuration in my app.
The users have the possibility to override this configuration so maybe a
user wants to direct the output of this logger to only one file. It seems
that setting the level "OFF" to this logger for one appender doesn't have
any effect here, the loggings are still directed to both files (knowing
that additivity is set to false).

 appender("appender1", RollingFileAppender) {
        file = "${logDir}/Test.log"
        encoder(PatternLayoutEncoder) {
            charset = Charset.forName('UTF-8')
            pattern = log_pattern
        }
        rollingPolicy(FixedWindowRollingPolicy) {
            fileNamePattern = "${logDir}/Test%i.log"
            minIndex = 1
            maxIndex = 2
        }
        triggeringPolicy(SizeBasedTriggeringPolicy) {
            maxFileSize = FileSize.valueOf("20MB")
        }
    }
    appender("appender2", RollingFileAppender) {
        file = "${logDir}/stacktrace.log"
        encoder(PatternLayoutEncoder) {
            charset = Charset.forName('UTF-8')
            pattern = log_pattern
        }
        rollingPolicy(FixedWindowRollingPolicy) {
            fileNamePattern = "${logDir}/stacktrace%i.log"
            minIndex = 1
            maxIndex = 2
        }
        triggeringPolicy(SizeBasedTriggeringPolicy) {
            maxFileSize = FileSize.valueOf("20MB")
        }
    }

    logger("org.geotools", OFF, ['appender1'], false)
    logger("org.geotools", TRACE, ['appender2'], false)

What should I do to be able to  disable the logger only in one appender?

Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20211130/1aff8b03/attachment.html>


More information about the logback-user mailing list