Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure logback to skip logging messages from org.package.* with all levels below WARN?

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?

like image 405
Vladislav Rastrusny Avatar asked May 07 '11 21:05

Vladislav Rastrusny


People also ask

How do I change the Logback configuration file?

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.

What are the log levels in Logback?

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().

How do I disable Logback logging?

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.

How do I set debug level in Logback?

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 .


2 Answers

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> 
like image 101
Tomasz Nurkiewicz Avatar answered Sep 20 '22 14:09

Tomasz Nurkiewicz


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

like image 25
thouliha Avatar answered Sep 19 '22 14:09

thouliha