Jason S
Jason S

Reputation: 189786

slf4j: any way to suppress the NOP error message?

If I use slf4j and the classpath doesn't contain a logger implementation, it defaults to a NOP logger operation. That's fine with me. But is there any way to suppress the initial error message?

 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
 SLF4J: Defaulting to no-operation (NOP) logger implementation
 SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Upvotes: 6

Views: 1754

Answers (1)

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340883

There are several ways and workarounds to achieve this:

  • Add built-in slf4j-nop binding to your CLASSPATH
  • Create your own binding that truly does nothing. More work, less hacky.
  • Override System.err by calling System.setErr() with some null implementation of PrintStream

Upvotes: 7

Related Questions