解决Failed to load class "org.slf4j.impl.StaticLoggerBinder"

来源:互联网 发布:sql server 修改语句 编辑:程序博客网 时间:2024/06/05 09:52

目录

  • 目录
    • 问题
    • 原因
    • 解决方案

问题

springmvc项目,使用的是log4j日志插件,项目启动时报以下错误

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

原因

意思是加载类文件org.slf4j.impl.StaticLoggerBinder类失败,应该是缺少了相关的jar包。这是因为slf4j-api包中只有方法定义,没有具体的方法实现,所以需要引入具体的实现包。

解决方案

官网解决方案如下:

This error is reported 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.

可以引入slf4j的实现包,如slf4j-log4j12.jar,引入后再启动项目就可以看到不在报错了。另外使用log4j2的话,可以引入log4j-slf4j-impl-2.10.0.jar包,这是log4j对slf4j相关方法的实现。

阅读全文
0 0
原创粉丝点击