背景
logback从1.2.x版本升级到1.3.x版本,发现不打日志。进程启动日志如下
Mar 14 00:58:48 legensec java[20681]: SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
Mar 14 00:58:48 legensec java[20681]: SLF4J: Defaulting to no-operation (NOP) logger implementation
Mar 14 00:58:48 legensec java[20681]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
解决
按照日志给的链接找到解决办法,将slf4j升级到配套的2.0.x版本,我们的项目是升级到2.0.7版本解决
Failed to load class org.slf4j.impl.StaticLoggerBinder
This warning message is reported by slf4j-api version 1.7.x and earlier when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.
If you are seeing this message, then you are NOT using slf4j-api version 2.0 or later but slf4j-api version 1.7.x or earlier. Slf4j-api versions 2.0.x and later use the ServiceLoader mechanism. Backends such as logback 1.3 and later which target slf4j-api 2.x, do not ship with org.slf4j.impl.StaticLoggerBinder. If you place a logging backend which targets slf4j-api 2.0.x, you need slf4j-api-2.x.jar on the classpath. See also relevant faq entry.
since 1.6.0 As of SLF4J version 1.6, in the absence of a binding, SLF4J will default to a no-operation (NOP) logger implementation.
If you are responsible for packaging an application and do not care about logging, then placing slf4j-nop.jar on the class path of your application will get rid of this warning message. Note that embedded components such as libraries or frameworks should not declare a dependency on any SLF4J binding (or provider) but only depend on slf4j-api. When a library declares a compile-time dependency on a SLF4J binding (or provider), it imposes that binding (or provider) on the end-user, thus negating SLF4J’s purpose.