I know there is a NullAppender
in log4j. But I can't find the appender in logback. Is there a better way for ignoring all logs in logback?
This is an old question, but the answers already given do not actually answer it.
Yes
There is a "null" appender, but that is not what it is called. I believe the logback author prefers the term "no-op" when referring to implementations that exist to satisfy some compile, test, or other design requirements, but do not actually perform any operation. The appender implementation that was originally asked about is:
ch.qos.logback.core.helpers.NOPAppender
javadoc
source
To add to ZachOfAllTrades' answer, here is a example logback.xml
that sets the root log level to INFO
but uses the NOPAppender
to log everything to nirvana:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="NOP" class="ch.qos.logback.core.helpers.NOPAppender"/>
<root level="INFO">
<appender-ref ref="NOP"/>
</root>
</configuration>
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