If I use slf4j and the classpat开发者_如何学编程h 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.
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 callingSystem.setErr()
with some null implementation ofPrintStream
精彩评论