SLF4J:无法加载类“ org.slf4j.impl.StaticLoggerBinder”

SLF4J在WebSphere 6.1部署时遇到无法加载类“org.slf4j.impl.StaticLoggerBinder”的问题。问题的根源在于缺少具体的日志实现,如log4j或logback。解决方案包括在类路径中添加适当的日志框架的jar文件,例如slf4j-jdk14-XXX.jar,或者确保完整的slf4j包已包含在内。
摘要由CSDN通过智能技术生成

本文翻译自:SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”

My application is to be deployed on both tcServer and WebSphere 6.1. 我的应用程序将同时部署在tcServer和WebSphere 6.1上。 This application uses ehCache and so requires slf4j as a dependency. 此应用程序使用ehCache,因此需要slf4j作为依赖项。 As a result I've added the slf4j-api.jar (1.6) jar to my war file bundle. 结果,我将slf4j-api.jar(1.6)jar添加到了我的war文件包中。

The application works fine in tcServer except for the following error: 该应用程序在tcServer中工作正常,但以下错误除外:

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.

However, when I deploy in WebSphere I get a java.lang.NoClassDefFoundError: org.slf4j.impl.StaticLoggerBinder . 但是,当我在WebSphere中部署时,我得到了一个java.lang.NoClassDefFoundError: org.slf4j.impl.StaticLoggerBinder

I've checked the classpaths of both application servers and there is no other slf4j jar. 我已经检查了两个应用服务器的类路径,没有其他的slf4j jar。

Does anyone have any ideas what may be happening here? 有谁知道这里可能会发生什么?


#1楼

参考:https://stackoom.com/question/V8hQ/SLF-J-无法加载类-org-slf-j-impl-StaticLoggerBinder


#2楼

将文件slf4j-log4j12-1.6.4.jar放在类路径中可以解决问题。


#3楼

SLF4j is an abstraction for various logging frameworks . SLF4j是各种日志框架的抽象。 Hence apart from having slf4j you need to include any of your logging framework like log4j or logback (etc) in your classpath. 因此,除了拥有slf4j之外,您还需要在类路径中包括任何日志记录框架,例如log4j或logback(etc)。
To have an idea refer the First Baby Step in http://logback.qos.ch/manual/introduction.html 要了解想法,请参见http://logback.qos.ch/manual/introduction.html中的“ 第一步”


#4楼

I am working in a project Struts2+Spring. 我在Struts2 + Spring项目中工作。 So it need a dependency slf4j-api-1.7.5.jar . 因此,它需要一个依赖项slf4j-api-1.7.5.jar

If I run the project, I am getting error like 如果我运行该项目,则会出现类似以下错误

Failed to load class "org.slf4j.impl.StaticLoggerBinder" 无法加载类“ org.slf4j.impl.StaticLoggerBinder”

I solved my problem by adding the slf4j-log4j12-1.7.5.jar . 我通过添加slf4j-log4j12-1.7.5.jar解决了我的问题。

So add this jar in your project to solve the issue. 因此,将此jar添加到您的项目中即可解决该问题。


#5楼

I know this post is a little old, but in case anyone else runs into this problem: 我知道这篇文章有些旧,但是万一其他人遇到了这个问题:

Add slf4j-jdk14-XXXjar to your CLASSPATH (where XXX is the version number - eg slf4j-jdk14-1.7.5.jar). 将slf4j-jdk14-XXXjar添加到您的CLASSPATH(其中XXX是版本号-例如slf4j-jdk14-1.7.5.jar)。

HTH Peter 彼得·HTH


#6楼

I got into this issue when I get the following error: 当出现以下错误时,我陷入了这个问题:

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.

when I was using slf4j-api-1.7.5.jar in my libs . 当我在libs使用slf4j-api-1.7.5.jar时。

Inspite I tried with the whole suggested complement jars, like slf4j-log4j12-1.7.5.jar , slf4j-simple-1.7.5 the error message still persisted. 尽管我尝试使用整个建议的补充jar,例如slf4j-log4j12-1.7.5.jarslf4j-simple-1.7.5但错误消息仍然存在。 The problem finally was solved when I added slf4j-jdk14-1.7.5.jar to the java libs. 当我将slf4j-jdk14-1.7.5.jar添加到Java库时,问题终于解决了。

Get the whole slf4j package at http://www.slf4j.org/download.html http://www.slf4j.org/download.html上获取整个slf4j软件包

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值