22

How do I configure logback not to log messages from loggers in package org.package and it's subpackages unless their level is WARN or ERROR?

Vladislav Rastrusny
  • 29,378
  • 23
  • 95
  • 156

2 Answers2

37

And why isn't the following configuration not working for you?

<configuration>
    <logger name="org.package" level="WARN"/>

    <root level="ALL">
        <appender class="ch.qos.logback.core.ConsoleAppender">
            <encoder>
                <pattern>%d{ISO8601} | %-5level | %thread | %logger{1} | %m%n</pattern>
            </encoder>
        </appender>
    </root>
</configuration>
Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
5

log.getLoggerContext().getLogger("package.name").setLevel(Level.WARN);

dessalines
  • 6,352
  • 5
  • 42
  • 59