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?
如何配置logback不要记录包org.package及其子包中记录器的消息,除非它们的级别是WARN或ERROR?
2 个解决方案
#1
35
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>
#2
5
log.getLoggerContext().getLogger("package.name").setLevel(Level.WARN);
。log.getLoggerContext()getLogger( “package.name”)setLevel(Level.WARN)。
#1
35
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>
#2
5
log.getLoggerContext().getLogger("package.name").setLevel(Level.WARN);
。log.getLoggerContext()getLogger( “package.name”)setLevel(Level.WARN)。