解决SLF4J和logback报错SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.

简介: 解决SLF4J和logback报错SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.

最近在Maven项目中实现日志模块时,利用 logback-classic 中本地(native)实现 SLF4J API(也表示依赖 slf4j-api)时遇到如下报错:

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.

Maven配置如下:

那么怎么解决这个问题呢?

首先想到的是否是版本不一致的问题,经过调试一番后,发现是logback版本太高,将版本降低后程序正常。

修改后运行就可以看到log了。

同时在网上浏览解决方法时也有其他同学遇到此报错,通过阅读后了解,实现日志模块导入的依赖有所不同。

另一种配置方法:

在slf4j-api的基础上可以添加slf4j-nop.jar slf4j-simple.jar, slf4j-log4j12.jar,slf4j-jdk14.jar或 logback-classic.jar中的其中一个jar包,一样可以实现日志模块。如下所示:

添加后也可以看到log。

相关文章
|
3月前
|
Java
flyway报错SLF4J: No SLF4J providers were found.或者SLF4J: Defaulting to no-operation (NOP) logger implem
flyway报错SLF4J: No SLF4J providers were found.或者SLF4J: Defaulting to no-operation (NOP) logger implem
122 1
|
4月前
|
Java 开发者
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Class path contains multiple SLF4J bindings.
20 0
|
6月前
log4j-slf4j
log4j-slf4j
29 0
|
Java Maven
SpringBoot中使用SLE4J日志框架启动报错:SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinde
SpringBoot中使用SLE4J日志框架启动报错:SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinde
513 1
|
分布式计算 Hadoop
SLF4J:Failed to load class org.slf4j.impl.StaticLoggerBinder.
SLF4J:Failed to load class org.slf4j.impl.StaticLoggerBinder.
264 0
|
Java Maven
Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log 解决方法
org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:400) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.jav
246 0
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.
133 0
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.
|
SQL 关系型数据库 MySQL
警告:SLF4J: Class path contains multiple SLF4J bindings.
警告:SLF4J: Class path contains multiple SLF4J bindings.
316 0
警告:SLF4J: Class path contains multiple SLF4J bindings.
|
分布式计算 Hadoop Java
SLF4J: Class path contains multiple SLF4J bindings.解决方案
SLF4J: Class path contains multiple SLF4J bindings.解决方案
664 0
SLF4J: Class path contains multiple SLF4J bindings.解决方案