SLF4J:未能加载类“org.slf4j.impl.StaticLoggerBinder”

时间:2022-11-21 00:39:03

My application is to be deployed on both tcServer and WebSphere 6.1. This application uses ehCache and so requires slf4j as a dependency. As a result I've added the slf4j-api.jar (1.6) jar to my war file bundle.

我的应用程序将部署在tcServer和WebSphere 6.1上。此应用程序使用ehCache,因此需要slf4j作为依赖项。因此,我添加了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?

有人知道这里会发生什么吗?

23 个解决方案

#1


359  

I had the same issue with WebSphere 6.1. As Ceki pointed out, there were tons of jars that WebSphere was using and one of them was pointing to an older version of slf4j.

我对WebSphere 6.1也有同样的问题。正如Ceki指出的,WebSphere使用了大量的jar,其中一个指向slf4j的旧版本。

The No-Op rollback happens only with slf4j -1.6+ so anything older than that will throw an exception and halts your deployment.

No-Op回滚只发生在slf4j -1.6+上,因此任何比它老的都将抛出一个异常,并停止部署。

There is a documentation in SLf4J site which resolves this. I followed that and added slf4j-simple-1.6.1.jar to my application along with slf4j-api-1.6.1.jar which I already had.

SLf4J站点中有一个文档可以解决这个问题。然后我添加了slf4j-simple-1.6.1。连同slf4j-api-1.6.1一起jar到我的应用程序。我已经有了。

This solved my issue. Hope it helps others who have this issue.

这解决了我的问题。希望它能帮助其他有这个问题的人。

#2


207  

This is for those who came here from google search.

这是为那些从谷歌搜索过来的人准备的。

If you use maven just add the following

如果您使用maven,请添加以下内容

   <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
       <version>1.7.5</version>
   </dependency>
   <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
       <version>1.7.5</version>
   </dependency>

Or

   <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
       <version>1.7.5</version>
   </dependency>
   <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
       <version>1.6.4</version>
   </dependency>

#3


37  

You need to add following jar file in your classpath: slf4j-simple-1.6.2.jar. If you don't have it, please download it. Please refer to http://www.slf4j.org/codes.html#multiple_bindings

您需要在类路径中添加以下jar文件:slf4j-simple-1.6.2.jar。如果没有,请下载。请参阅http://www.slf4j.org/codes.html multiple_bindings

#4


12  

Simply add this to your pom.xml:

只需将此添加到您的pom.xml:

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-simple</artifactId>
  <version>1.7.21</version>
</dependency>

#5


12  

put file slf4j-log4j12-1.6.4.jar in the classpath will do the trick.

把文件slf4j-log4j12-1.6.4。类路径中的jar就可以了。

#6


11  

Sometime we should see the note from the warning, for example. SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details..

例如,有时我们应该看到警告中的注释。SLF4J:详情请参见http://www.slf4j.org/codes.html#StaticLoggerBinder。

You can search the reason why this warning comes.
Adding one of the jar from *slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar* to the class path should solve the problem.

你可以搜索这个警告的原因。从*slf4j-nop中添加一个jar。slf4j-simple jar。slf4j-log4j12 jar。slf4j-jdk14 jar。jar或logback-classic。jar*到类路径应该可以解决这个问题。

compile "org.slf4j:slf4j-api:1.6.1" compile "org.slf4j:slf4j-simple:1.6.1"

“编译”编译”org.slf4j:slf4j-api:1.6.1 org.slf4j:slf4j-simple:1.6.1”

for example add the above code to your build.gradle or the corresponding code to pom.xml for maven project.

例如,将上面的代码添加到您的构建中。等级或相应的代码到pom。xml maven项目。

#7


9  

If you are using maven to dependency management so you can just add following dependency in pom.xml

如果您正在使用maven来进行依赖管理,那么您只需在jms .xml中添加以下依赖项

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.5.6</version>
</dependency>

For non-Maven users Just download the library and put it into your project classpath.

对于非maven用户,只需下载库并将其放入项目类路径。

Here you can see details: http://www.mkyong.com/wicket/java-lang-classnotfoundexception-org-slf4j-impl-staticloggerbinder/

在这里,您可以看到详细信息:http://www.mkyong.com/wicket/java-lang- classnotfoundexcep-org- slf4j-impl-staticloggerbinder/

#8


7  

SLF4j is an abstraction for various logging frameworks. Hence apart from having slf4j you need to include any of your logging framework like log4j or logback (etc) in your classpath.
To have an idea refer the First Baby Step in http://logback.qos.ch/manual/introduction.html

SLF4j是各种日志框架的抽象。因此,除了拥有slf4j之外,还需要在类路径中包含任何日志框架,如log4j或logback(等等)。要有想法,请参考http://logback.qos.ch/manual/tion.html中的第一步

#9


7  

I was facing same error. I have configured slf4j-api, slf4j-log4j12 and log4j, in my local development. All configuration was fine, but slf4j-log4j12 dependency which I copied from mvnrepository had test scope <scope>test</scope>. When I removed this every thing is fine.

我也面临同样的错误。我已经在本地开发中配置了slf4j-api、slf4j-log4j12和log4j。所有配置都没问题,但是我从mvnrepository复制的slf4j-log4j12依赖项的测试范围 <范围> 测试 。当我把它拿掉的时候,一切都没问题。

Some times silly mistakes breaks our head ;)

有时愚蠢的错误会让我们的头脑崩溃;

#10


5  

Slf4j is a facade for the underlying logging frameworks like log4j, logback, java.util.logging.

Slf4j是底层日志记录框架的facade,如log4j、logback、java.util.logging。

To connect with underlying frameworks, slf4j uses a binding.

要连接底层框架,slf4j使用绑定。

  • log4j - slf4j-log4j12-1.7.21.jar
  • log4j - slf4j-log4j12-1.7.21.jar
  • java.util.logging - slf4j-jdk14-1.7.21.jar etc
  • java.util。日志——slf4j-jdk14-1.7.21。罐等

The above error is thrown if the binding jar is missed. You can download this jar and add it to classpath.

如果错过绑定jar,将抛出上面的错误。您可以下载这个jar并将其添加到类路径中。

For maven dependency,

对于maven的依赖,

<dependency> 
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
  <version>1.7.21</version>
</dependency>

This dependency in addition to slf4j-log4j12-1.7.21.jar,it will pull slf4j-api-1.7.21.jar as well as log4j-1.2.17.jar into your project

除了slf4j-log4j12-1.7.21之外的这个依赖项。jar,它将把slf4j-api-1.7.21。jar和log4j-1.2.17一样。jar到您的项目

Reference: http://www.slf4j.org/manual.html

参考:http://www.slf4j.org/manual.html

#11


4  

In the Websphere case, you have an older version of slf4j-api.jar, 1.4.x. or 1.5.x lying around somewhere. The behavior you observe on tcServer, that is fail-over to NOP, occurs on slf4j versions 1.6.0 and later. Make sure that you are using slf4j-api-1.6.x.jar on all platforms and that no older version of slf4j-api is placed on the class path.

在Websphere中,您拥有slf4j-api的旧版本。1.4.x jar。或1.5。x躺在某个地方。您在tcServer上观察到的行为,即故障转移到NOP,发生在slf4j版本1.6.0以及以后的版本中。确保您正在使用slf4j-api-1.6.x。jar在所有平台上,并且没有旧版本的slf4j-api放在类路径上。

#12


4  

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.

当我使用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. The problem finally was solved when I added slf4j-jdk14-1.7.5.jar to the java libs.

尽管我尝试了所有建议的补体jar,比如slf4j-log4j12-1.7.5。错误消息仍然持续存在。当我添加slf4j-jdk14-1.7.5时,问题终于解决了。jar到java libs。

Get the whole slf4j package at http://www.slf4j.org/download.html

在http://www.slf4j.org/download.html获取整个slf4j包

#13


4  

Please add the following dependencies to pom to resolve this issue.

请向pom添加以下依赖项以解决此问题。

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-simple</artifactId>
  <version>1.7.25</version>
  <scope>test</scope>
</dependency>

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-api</artifactId>
  <version>1.7.25</version>
</dependency>

#14


4  

Quite a few answers here recommend adding the slf4j-simple dependency to your maven pom file. You might want to check for the most current version.

这里有很多答案建议将slf4j-simple依赖项添加到maven pom文件中。您可能需要检查当前的版本。

At https://mvnrepository.com/artifact/org.slf4j/slf4j-simple you'll find the latest version of the SLF4J Simple Binding. Pick the one that suites you best (still 1.7.25 from 2017-03 is the stable version as of 2018-02) and include it to your pom.xml.

在https://mvnrepository.com/artifact/org.slf4j/slf4j-simple,您将找到SLF4J简单绑定的最新版本。选择最适合您的版本(仍然是2017-03年的1.7.25,是2018-02年的稳定版本),并将其包含到您的pom.xml中。

You might want to remove the scope tag to make the dependency available in non - test cases.

您可能想要删除作用域标记,使依赖关系在非测试用例中可用。

Beta Version of January 2018

2018年1月的测试版

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-simple</artifactId>
  <version>1.8.0-beta1</version>
</dependency>

Stable Version

稳定的版本

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.25</version>
</dependency>

#15


2  

I am working in a project Struts2+Spring. So it need a dependency slf4j-api-1.7.5.jar.

我在Struts2+Spring项目中工作。所以它需要一个依赖项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来解决这个问题。

#16


2  

I was facing the similar problem with Spring-boot-2 applications with Java 9 library.

我在使用Java 9库的Spring-boot-2应用程序时遇到了类似的问题。

Adding the following dependency in my pom.xml solved the issue for me:

在pom中添加以下依赖项。xml为我解决了这个问题:

    <dependency>
        <groupId>com.googlecode.slf4j-maven-plugin-log</groupId>
        <artifactId>slf4j-maven-plugin-log</artifactId>
        <version>1.0.0</version>
    </dependency>

#17


1  

I added this dependency to resolve this issue:

我添加了这个依赖项来解决这个问题:

https://mvnrepository.com/artifact/org.slf4j/slf4j-simple/1.7.25

#18


0  

I know this post is a little old, but in case anyone else runs into this problem:

我知道这篇文章有点过时了,但万一有人遇到这个问题:

Add slf4j-jdk14-X.X.X.jar to your CLASSPATH (where X.X.X is the version number - e.g. slf4j-jdk14-1.7.5.jar).

添加slf4j-jdk14-X.X.X。jar到类路径(其中x . x。X是版本号—例如slf4j-jdk14-1.7.5 jar)。

HTH Peter

HTH彼得

#19


0  

According to SLF4J official documentation

根据SLF4J的官方文档

Failed to load class org.slf4j.impl.StaticLoggerBinder

未能加载类org.slf4j.impl.StaticLoggerBinder

This warning message 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.

当org.slf4j.impl报告此警告消息。无法将StaticLoggerBinder类加载到内存中。当在类路径上找不到合适的SLF4J绑定时,就会发生这种情况。放置一个(并且只有一个)slf4j-nop。slf4j-simple jar。slf4j-log4j12 jar。slf4j-jdk14 jar。jar或logback-classic。jar在类路径上应该可以解决这个问题。

Simply add this jar along with slf4j api.jar to your classpath to get things done. Best of luck

只需添加这个jar和slf4j api。jar到类路径中完成任务。最好的运气

#20


0  

I use Jena and I add the fellowing dependence to pom.xml

我使用Jena,并添加了对pom.xml的依赖

<dependency> 
  <groupId>ch.qos.logback</groupId>
  <artifactId>logback-classic</artifactId>
  <version>1.0.13</version>
</dependency>

I try to add slf4j-simple but it just disappear the "SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”" error but logback-classic show more detail infomation.

我尝试添加SLF4J -simple,但它只是消失了“SLF4J:未能加载类”org.slf4j.impl。StaticLoggerBinder“”错误,但是logback-classic显示了更多的细节信息。

The official document

官方的文档

#21


0  

I solve it adding this library: slf4j-simple-1.7.25.jar You can download this in official web https://www.slf4j.org/download.html

我解决了添加这个库的问题:slf4j-simple-1.7.25。jar你可以在官方网站https://www.slf4j.org/download.html下载

#22


0  

the solution is indicated on their official website :

解决方案在他们的官方网站上指出:

Failed to load class org.slf4j.impl.StaticLoggerBinder

未能加载类org.slf4j.impl.StaticLoggerBinder

This warning message 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. 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 but only depend on slf4j-api. When a library declares a compile-time dependency on a SLF4J binding, it imposes that binding on the end-user, thus negating SLF4J's purpose.

当org.slf4j.impl报告此警告消息。无法将StaticLoggerBinder类加载到内存中。当在类路径上找不到合适的SLF4J绑定时,就会发生这种情况。放置一个(并且只有一个)slf4j-nop。jar slf4j-simple。slf4j-log4j12 jar。slf4j-jdk14 jar。jar或logback-classic。在类路径上的jar应该可以解决这个问题。因为从SLF4J版本1.6开始,在没有绑定的情况下,SLF4J将默认为无操作日志记录器实现。如果您负责打包应用程序,而不关心日志记录,则放置slf4j-nop。应用程序的类路径上的jar将删除此警告消息。注意,嵌入式组件(如库或框架)不应该声明对任何SLF4J绑定的依赖,而应该只依赖于SLF4J -api。当库声明对SLF4J绑定的编译时依赖时,它将绑定强加给最终用户,从而否定了SLF4J的目的。

solution : I have added to my project using maven research on intellij and i have chosen the slf4j-jdk14.jar.

解决方案:我使用intellij上的maven research来增加我的项目,我选择了slf4j-jdk14.jar。

#23


0  

As an alternative to the jar inclusion and pure maven solutions, you can include it from maven with gradle.

作为jar包和纯maven解决方案的替代方案,您可以将它从maven和gradle中包括进来。

Example for version 1.7.25

// https://mvnrepository.com/artifact/org.slf4j/slf4j-simple
api group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'

Put this within the dependencies of your build.gradle file.

将其放在构建的依赖项中。gradle文件。

#1


359  

I had the same issue with WebSphere 6.1. As Ceki pointed out, there were tons of jars that WebSphere was using and one of them was pointing to an older version of slf4j.

我对WebSphere 6.1也有同样的问题。正如Ceki指出的,WebSphere使用了大量的jar,其中一个指向slf4j的旧版本。

The No-Op rollback happens only with slf4j -1.6+ so anything older than that will throw an exception and halts your deployment.

No-Op回滚只发生在slf4j -1.6+上,因此任何比它老的都将抛出一个异常,并停止部署。

There is a documentation in SLf4J site which resolves this. I followed that and added slf4j-simple-1.6.1.jar to my application along with slf4j-api-1.6.1.jar which I already had.

SLf4J站点中有一个文档可以解决这个问题。然后我添加了slf4j-simple-1.6.1。连同slf4j-api-1.6.1一起jar到我的应用程序。我已经有了。

This solved my issue. Hope it helps others who have this issue.

这解决了我的问题。希望它能帮助其他有这个问题的人。

#2


207  

This is for those who came here from google search.

这是为那些从谷歌搜索过来的人准备的。

If you use maven just add the following

如果您使用maven,请添加以下内容

   <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
       <version>1.7.5</version>
   </dependency>
   <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
       <version>1.7.5</version>
   </dependency>

Or

   <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
       <version>1.7.5</version>
   </dependency>
   <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
       <version>1.6.4</version>
   </dependency>

#3


37  

You need to add following jar file in your classpath: slf4j-simple-1.6.2.jar. If you don't have it, please download it. Please refer to http://www.slf4j.org/codes.html#multiple_bindings

您需要在类路径中添加以下jar文件:slf4j-simple-1.6.2.jar。如果没有,请下载。请参阅http://www.slf4j.org/codes.html multiple_bindings

#4


12  

Simply add this to your pom.xml:

只需将此添加到您的pom.xml:

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-simple</artifactId>
  <version>1.7.21</version>
</dependency>

#5


12  

put file slf4j-log4j12-1.6.4.jar in the classpath will do the trick.

把文件slf4j-log4j12-1.6.4。类路径中的jar就可以了。

#6


11  

Sometime we should see the note from the warning, for example. SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details..

例如,有时我们应该看到警告中的注释。SLF4J:详情请参见http://www.slf4j.org/codes.html#StaticLoggerBinder。

You can search the reason why this warning comes.
Adding one of the jar from *slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar* to the class path should solve the problem.

你可以搜索这个警告的原因。从*slf4j-nop中添加一个jar。slf4j-simple jar。slf4j-log4j12 jar。slf4j-jdk14 jar。jar或logback-classic。jar*到类路径应该可以解决这个问题。

compile "org.slf4j:slf4j-api:1.6.1" compile "org.slf4j:slf4j-simple:1.6.1"

“编译”编译”org.slf4j:slf4j-api:1.6.1 org.slf4j:slf4j-simple:1.6.1”

for example add the above code to your build.gradle or the corresponding code to pom.xml for maven project.

例如,将上面的代码添加到您的构建中。等级或相应的代码到pom。xml maven项目。

#7


9  

If you are using maven to dependency management so you can just add following dependency in pom.xml

如果您正在使用maven来进行依赖管理,那么您只需在jms .xml中添加以下依赖项

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.5.6</version>
</dependency>

For non-Maven users Just download the library and put it into your project classpath.

对于非maven用户,只需下载库并将其放入项目类路径。

Here you can see details: http://www.mkyong.com/wicket/java-lang-classnotfoundexception-org-slf4j-impl-staticloggerbinder/

在这里,您可以看到详细信息:http://www.mkyong.com/wicket/java-lang- classnotfoundexcep-org- slf4j-impl-staticloggerbinder/

#8


7  

SLF4j is an abstraction for various logging frameworks. Hence apart from having slf4j you need to include any of your logging framework like log4j or logback (etc) in your classpath.
To have an idea refer the First Baby Step in http://logback.qos.ch/manual/introduction.html

SLF4j是各种日志框架的抽象。因此,除了拥有slf4j之外,还需要在类路径中包含任何日志框架,如log4j或logback(等等)。要有想法,请参考http://logback.qos.ch/manual/tion.html中的第一步

#9


7  

I was facing same error. I have configured slf4j-api, slf4j-log4j12 and log4j, in my local development. All configuration was fine, but slf4j-log4j12 dependency which I copied from mvnrepository had test scope <scope>test</scope>. When I removed this every thing is fine.

我也面临同样的错误。我已经在本地开发中配置了slf4j-api、slf4j-log4j12和log4j。所有配置都没问题,但是我从mvnrepository复制的slf4j-log4j12依赖项的测试范围 <范围> 测试 。当我把它拿掉的时候,一切都没问题。

Some times silly mistakes breaks our head ;)

有时愚蠢的错误会让我们的头脑崩溃;

#10


5  

Slf4j is a facade for the underlying logging frameworks like log4j, logback, java.util.logging.

Slf4j是底层日志记录框架的facade,如log4j、logback、java.util.logging。

To connect with underlying frameworks, slf4j uses a binding.

要连接底层框架,slf4j使用绑定。

  • log4j - slf4j-log4j12-1.7.21.jar
  • log4j - slf4j-log4j12-1.7.21.jar
  • java.util.logging - slf4j-jdk14-1.7.21.jar etc
  • java.util。日志——slf4j-jdk14-1.7.21。罐等

The above error is thrown if the binding jar is missed. You can download this jar and add it to classpath.

如果错过绑定jar,将抛出上面的错误。您可以下载这个jar并将其添加到类路径中。

For maven dependency,

对于maven的依赖,

<dependency> 
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
  <version>1.7.21</version>
</dependency>

This dependency in addition to slf4j-log4j12-1.7.21.jar,it will pull slf4j-api-1.7.21.jar as well as log4j-1.2.17.jar into your project

除了slf4j-log4j12-1.7.21之外的这个依赖项。jar,它将把slf4j-api-1.7.21。jar和log4j-1.2.17一样。jar到您的项目

Reference: http://www.slf4j.org/manual.html

参考:http://www.slf4j.org/manual.html

#11


4  

In the Websphere case, you have an older version of slf4j-api.jar, 1.4.x. or 1.5.x lying around somewhere. The behavior you observe on tcServer, that is fail-over to NOP, occurs on slf4j versions 1.6.0 and later. Make sure that you are using slf4j-api-1.6.x.jar on all platforms and that no older version of slf4j-api is placed on the class path.

在Websphere中,您拥有slf4j-api的旧版本。1.4.x jar。或1.5。x躺在某个地方。您在tcServer上观察到的行为,即故障转移到NOP,发生在slf4j版本1.6.0以及以后的版本中。确保您正在使用slf4j-api-1.6.x。jar在所有平台上,并且没有旧版本的slf4j-api放在类路径上。

#12


4  

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.

当我使用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. The problem finally was solved when I added slf4j-jdk14-1.7.5.jar to the java libs.

尽管我尝试了所有建议的补体jar,比如slf4j-log4j12-1.7.5。错误消息仍然持续存在。当我添加slf4j-jdk14-1.7.5时,问题终于解决了。jar到java libs。

Get the whole slf4j package at http://www.slf4j.org/download.html

在http://www.slf4j.org/download.html获取整个slf4j包

#13


4  

Please add the following dependencies to pom to resolve this issue.

请向pom添加以下依赖项以解决此问题。

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-simple</artifactId>
  <version>1.7.25</version>
  <scope>test</scope>
</dependency>

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-api</artifactId>
  <version>1.7.25</version>
</dependency>

#14


4  

Quite a few answers here recommend adding the slf4j-simple dependency to your maven pom file. You might want to check for the most current version.

这里有很多答案建议将slf4j-simple依赖项添加到maven pom文件中。您可能需要检查当前的版本。

At https://mvnrepository.com/artifact/org.slf4j/slf4j-simple you'll find the latest version of the SLF4J Simple Binding. Pick the one that suites you best (still 1.7.25 from 2017-03 is the stable version as of 2018-02) and include it to your pom.xml.

在https://mvnrepository.com/artifact/org.slf4j/slf4j-simple,您将找到SLF4J简单绑定的最新版本。选择最适合您的版本(仍然是2017-03年的1.7.25,是2018-02年的稳定版本),并将其包含到您的pom.xml中。

You might want to remove the scope tag to make the dependency available in non - test cases.

您可能想要删除作用域标记,使依赖关系在非测试用例中可用。

Beta Version of January 2018

2018年1月的测试版

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-simple</artifactId>
  <version>1.8.0-beta1</version>
</dependency>

Stable Version

稳定的版本

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.25</version>
</dependency>

#15


2  

I am working in a project Struts2+Spring. So it need a dependency slf4j-api-1.7.5.jar.

我在Struts2+Spring项目中工作。所以它需要一个依赖项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来解决这个问题。

#16


2  

I was facing the similar problem with Spring-boot-2 applications with Java 9 library.

我在使用Java 9库的Spring-boot-2应用程序时遇到了类似的问题。

Adding the following dependency in my pom.xml solved the issue for me:

在pom中添加以下依赖项。xml为我解决了这个问题:

    <dependency>
        <groupId>com.googlecode.slf4j-maven-plugin-log</groupId>
        <artifactId>slf4j-maven-plugin-log</artifactId>
        <version>1.0.0</version>
    </dependency>

#17


1  

I added this dependency to resolve this issue:

我添加了这个依赖项来解决这个问题:

https://mvnrepository.com/artifact/org.slf4j/slf4j-simple/1.7.25

#18


0  

I know this post is a little old, but in case anyone else runs into this problem:

我知道这篇文章有点过时了,但万一有人遇到这个问题:

Add slf4j-jdk14-X.X.X.jar to your CLASSPATH (where X.X.X is the version number - e.g. slf4j-jdk14-1.7.5.jar).

添加slf4j-jdk14-X.X.X。jar到类路径(其中x . x。X是版本号—例如slf4j-jdk14-1.7.5 jar)。

HTH Peter

HTH彼得

#19


0  

According to SLF4J official documentation

根据SLF4J的官方文档

Failed to load class org.slf4j.impl.StaticLoggerBinder

未能加载类org.slf4j.impl.StaticLoggerBinder

This warning message 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.

当org.slf4j.impl报告此警告消息。无法将StaticLoggerBinder类加载到内存中。当在类路径上找不到合适的SLF4J绑定时,就会发生这种情况。放置一个(并且只有一个)slf4j-nop。slf4j-simple jar。slf4j-log4j12 jar。slf4j-jdk14 jar。jar或logback-classic。jar在类路径上应该可以解决这个问题。

Simply add this jar along with slf4j api.jar to your classpath to get things done. Best of luck

只需添加这个jar和slf4j api。jar到类路径中完成任务。最好的运气

#20


0  

I use Jena and I add the fellowing dependence to pom.xml

我使用Jena,并添加了对pom.xml的依赖

<dependency> 
  <groupId>ch.qos.logback</groupId>
  <artifactId>logback-classic</artifactId>
  <version>1.0.13</version>
</dependency>

I try to add slf4j-simple but it just disappear the "SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”" error but logback-classic show more detail infomation.

我尝试添加SLF4J -simple,但它只是消失了“SLF4J:未能加载类”org.slf4j.impl。StaticLoggerBinder“”错误,但是logback-classic显示了更多的细节信息。

The official document

官方的文档

#21


0  

I solve it adding this library: slf4j-simple-1.7.25.jar You can download this in official web https://www.slf4j.org/download.html

我解决了添加这个库的问题:slf4j-simple-1.7.25。jar你可以在官方网站https://www.slf4j.org/download.html下载

#22


0  

the solution is indicated on their official website :

解决方案在他们的官方网站上指出:

Failed to load class org.slf4j.impl.StaticLoggerBinder

未能加载类org.slf4j.impl.StaticLoggerBinder

This warning message 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. 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 but only depend on slf4j-api. When a library declares a compile-time dependency on a SLF4J binding, it imposes that binding on the end-user, thus negating SLF4J's purpose.

当org.slf4j.impl报告此警告消息。无法将StaticLoggerBinder类加载到内存中。当在类路径上找不到合适的SLF4J绑定时,就会发生这种情况。放置一个(并且只有一个)slf4j-nop。jar slf4j-simple。slf4j-log4j12 jar。slf4j-jdk14 jar。jar或logback-classic。在类路径上的jar应该可以解决这个问题。因为从SLF4J版本1.6开始,在没有绑定的情况下,SLF4J将默认为无操作日志记录器实现。如果您负责打包应用程序,而不关心日志记录,则放置slf4j-nop。应用程序的类路径上的jar将删除此警告消息。注意,嵌入式组件(如库或框架)不应该声明对任何SLF4J绑定的依赖,而应该只依赖于SLF4J -api。当库声明对SLF4J绑定的编译时依赖时,它将绑定强加给最终用户,从而否定了SLF4J的目的。

solution : I have added to my project using maven research on intellij and i have chosen the slf4j-jdk14.jar.

解决方案:我使用intellij上的maven research来增加我的项目,我选择了slf4j-jdk14.jar。

#23


0  

As an alternative to the jar inclusion and pure maven solutions, you can include it from maven with gradle.

作为jar包和纯maven解决方案的替代方案,您可以将它从maven和gradle中包括进来。

Example for version 1.7.25

// https://mvnrepository.com/artifact/org.slf4j/slf4j-simple
api group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'

Put this within the dependencies of your build.gradle file.

将其放在构建的依赖项中。gradle文件。