Does the magazine have a NullAppender?

I know that NullAppender has NullAppender . But I can not find the application in the log. Is there a better way to ignore all logs in a log?

+6
source share
4 answers

Setting the log level to OFF will ignore all logs.

 <logger name="..." level="OFF" /> 
+4
source

This is an old question, but the answers that have already been given do not really answer it.

Yes

There is a zero application, but that’s not what it is called. I believe that the author of the magazine prefers the term "no-op" when referring to implementations that exist to satisfy some compilation, test or other design requirements, but actually do not perform any operation. The appender implementation was originally asked:

 ch.qos.logback.core.helpers.NOPAppender 

javadoc

a source

+6
source

You can always write one:

 public class NullAppender extends UnsynchronizedAppenderBase<ILoggingEvent> { @Override protected void append(ILoggingEvent eventObject) { //no-op } } 
+4
source

Just curious, what's the point of using NullAppender (which I believe is an Appender that does nothing), while you might just not install any application in the log?

And the right way to turn off the entire log is to set the log level to OFF.


With a comment from @djechlin, I find the filters in LogBack also worth mentioning. If you just want to disable all messages passing through the application, you can simply use the Threshold Filter:

 <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <!-- Deny everything below OFF, that means deny everything --> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>OFF</level> </filter> .... other config </appender> 
+3
source

Source: https://habr.com/ru/post/949291/


All Articles