Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging different level for a specific class using logback?

Tags:

Can I override a logging level for a specific class only using logback.xml? i.e everything remains in INFO, except for one class which will log in DEBUG.

I appended this after the default one, but does not seem to work

<logger name="com.pack1.pack2.paack3.ClassName" additivity="false" level="debug">
    <appender-ref ref="file1"/>
</logger>

Thanks, Donald

like image 972
Donald Avatar asked Jun 14 '13 11:06

Donald


People also ask

How do you filter Logback logs?

In logback-classic, filters can be added to Appender instances. By adding one or more filters to an appender, you can filter events by arbitrary criteria, such as the contents of the log message, the contents of the MDC, the time of day or any other part of the logging event.

What is root level in Logback?

"Root" level does not restrict levels of other loggers, it merely sets the default. So <root level="INFO"> and <logger name="some.name" level="DEBUG"> are perfectly suitable together, and you don't need to relax the "root" level. So both examples should log on debug level for logger named com.


1 Answers

Doing it exactly like this works for me:

<logger name="org.apache.zookeeper" level="WARN" />
like image 136
F. P. Freely Avatar answered Sep 21 '22 21:09

F. P. Freely