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?
Setting the location of the configuration file via a system property. You may specify the location of the default configuration file with a system property named "logback. configurationFile" . The value of this property can be a URL, a resource on the class path or a path to a file external to the application.
Loggers are the third main component of Logback, which developers can use to log messages at a certain level. The library defines 5 log levels: TRACE, DEBUG, INFO, WARN, ERROR; each of these has a corresponding logging method: trace(), debug(), info(), warn(), error().
Logback does not allow logging to be disabled from the command line. However, if the configuration file allows it, you can set the level of loggers on the command line via a Java system property.
debug=true to enable debugging of the logback setup. Unfortunately, there is no way to enable debugging via a System property. You have to use <configuration debug="true"> in the logback. xml .
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>
log.getLoggerContext().getLogger("package.name").setLevel(Level.WARN);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With