SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". error
Asked Answered
O

12

124
  • Regarding Eclipse IDE (Indigo, Juno and Kepler (32 and 64 bit versions))
  • Platforms: Windows, Ubuntu, Mac
  • m2e version: 1.1.0.20120530-0009, 1.2.0.20120903-1050, 1.3.0.20130129-0926,
    1.4.0.20130601-0317

General info

The above error came after updating the m2e to version 1.1. By removing m2e 1.1 and rolling back to m2e 1.0 everything worked fine. I tried to repeat the problem in Windows and Ubuntu and it gave me the exact same error. Numerous configurations of the slf4j-api and logback were tested but none seem to work.

The error appears in any maven project even without declaring slf4j dependency.

  • New Maven Project--> maven-archetype-quickstart

    and

  • New Maven Project--> Simple project without archetype selection

    result to

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

Testing enviroments and configurations

Tested with Eclipse Indigo and Eclipse Juno (32 and 64 bit both) on Mac, 32 bit on Ubuntu and 64 and 32 bit on Windows. Tested fresh installs of Juno Classic, Juno Modelling tools, Kepler Standard, Kepler Modelling Tools and produced the same error.

The error appears with clean, install, test, deploy, generate-sources, validate , compile , package, integration-test, verify and combinations of the goal clean with the rest goals. It appears also with parameters -e and -X. There was an attempt to delete the m2e repository and download it from scratch but again without success. It should me mentioned that it was tested in 3 different machines and virtual box all the above systems but it produced the same error.

Tried all different logback configurations (from 1.0.4 to 1.0.13) that resolve the slf4j-api and logback-core dependencies, but all produce the same error:

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

Tried all different (from 1.6.1 to 1.7.5 ) slf4j-simple configurations.

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

Tried all different (from 1.6.1 to 1.7.5 ) log4j-over-slf4j configurations.

<dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>log4j-over-slf4j</artifactId>
   <version></version>
   <scope>compile</scope>
</dependency>

Tried all different (from 1.6.1 to 1.7.5 ) slf4j-jdk14 configurations.

<dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-jdk14</artifactId>
   <version></version>
   <scope>compile</scope>
</dependency>

Tried all different (from 1.6.1 to 1.7.5 ) slf4j-log4j12 configurations.

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

Tried slf4j-nop 1.7.5 configuration.

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-nop</artifactId>
  <version>1.7.5</version>
  <scope>compile</scope>
</dependency>

Last but not least the logs are saved and printed despite the error.


Ways to reproduce the error

  • Download Eclipse Juno, Indigo or Kepler 32 or 64 bit (All installations will cause the same error).

  • Right Click on the project->Runs As->clean install (or any other goal mentioned above)

The first line on the console will be

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.

P.S. Existing projects will produce the same error after updating the m2e version to 1.1.0.20120530-0009, 1.2.0.20120903-1050, 1.3.0.20130129-0926, 1.4.0.20130601-0317


Updates

EDIT

m2e support site:

  • The above question was posted as a bug in m2e support site and the answer from Igor Fedorenko was that

    There are no immediate plans to suppress this message.

    For viewing the above bug please refer to m2e official support site


EDIT 2
  • The above error indication is present also to m2e version 1.2.0.20120903-1050


EDIT 3
  • The above error indication is present also to m2e version 1.3.0.20130129-0926


EDIT 4
  • The above error indication is present also to m2e version 1.4.0.20130601-0317


EDIT 5
                              ***Reported FIXED***
  • The above error is reported as fixed for m2e version 1.5.0/Luna M3(Target Milestone). The version is not yet available for download.
  • Luna M3 is scheduled for Nov. 15th.
  • Latest dev build are available here
  • More information about the m2e milestones you can find at the m2e main repository.
Overcheck answered 11/8, 2012 at 18:44 Comment(6)
@EliranMalka It is long but with a reason. Trying to help people to avoid asking the same questions and include every detail that might seem necessary in order to understand if they are facing the same problem didn't let me too many choices. :-)Overcheck
I got this error while trying to use spring data with neo4j I have slf4j in both slf4j-api-1.7.7 and jcl-over-slf4j-1.7.7 and if I try to remove anyone of them I get an error message saying that their Logger class is missing. What should I do?Gaiser
@KonstantinosMargaritis can you please tell how to fix this with pom.xml , I could get it working on local setup but on jenkins it's always failing.Yeeyegg
What is your current setup @vikramvi?Overcheck
@KonstantinosMargaritis thanks for getting back on this . I realized maven was 3.0 version on Linux upgraded to latest version and tried again. this fixed the issue. But had to spend whole day trying to find out what may be wrong. Thanks anyways.Yeeyegg
You are welcome @vikramvi! Happy you solved it :-)Overcheck
S
75

I can also confirm this error.

Workaround: is to use external maven inside m2eclipse, instead of it's embedded maven.

That is done in three steps:

1 Install maven on local machine (the test-machine was Ubuntu 10.10)

mvn --version

Apache Maven 2.2.1 (rdebian-4) Java version: 1.6.0_20 Java home: /usr/lib/jvm/java-6-openjdk/jre Default locale: de_DE, platform encoding: UTF-8 OS name: "linux" version: "2.6.35-32-generic" arch: "amd64" Family: "unix"

2 Run maven externally link how to run maven from console

> cd path-to-pom.xml
> mvn test
    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Simple
    [INFO]    task-segment: [test]
    [INFO] ------------------------------------------------------------------------
    [...]
    [INFO] Surefire report directory: [...]/workspace/Simple/target/surefire-reports
    
    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running net.tverrbjelke.experiment.MainAppTest
    Hello World
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.042 sec
    
    Results :
    
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
    
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] ------------------------------------------------------------------------
    [...]

3 inside m2eclipse: switch from embedded maven to local maven

  • find out where local maven home installation dir is (mvn --version, or google for your MAVEN_HOME, for me this helped me that is /usr/share/maven2 )
  • in eclipse Menu->Window->Preferences->Maven->Installation-> enter that string. Then you should have switched to your new external maven.
  • then run your Project as e.g. "maven test".

The error-message should be gone.

Snowball answered 11/9, 2012 at 15:41 Comment(5)
I am accepting your answer since it is the only workaround in order to bypass the annoying error. Thank you very much for your analytical answer. :)..Overcheck
hmm I am on Windows and changed to the new external installations, however the error still exists!?Allsopp
sorry, it works. Note that there is an option for the maven runtime (internal/external) on the run configurations. so if you use a saved one, make sure to update it.Allsopp
@stefan.at.wpf Good to hear that it works. If you want, you can subscribe in the mailing list of the bug and you can get informed in case something changes.Overcheck
For me, #mvn --version is convenient to show the MAVEN_HOME.Munda
D
26

There is a documentation in SLf4J site to resolve this. I followed that and added slf4j-simple-1.6.1.jar to my aplication along with slf4j-api-1.6.1.jar which i already had.This solved my problem

slf4j

Dig answered 23/5, 2014 at 10:6 Comment(3)
this works, in maven can add: <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.X.X</version> </dependency> //Just replace with your versionAtalayah
@Mohammed Irfan may i need to add this twojar in libs folder in eclipse ?Pavid
I am using a later version of Maven and had followed the steps above, but this was the answer that caused the issue to go away - thanks :)Aqualung
C
21

If you are using Gradle add this:

dependencies { 
... 
compile "org.slf4j:slf4j-simple:1.7.9" 
... 
}
Christos answered 23/12, 2016 at 4:56 Comment(1)
It works here with Gradle !! Can you explain what happen when we add that library ?Polinski
O
5

Paste this code to your pom.xml file. It works for me.

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.6.1</version>
    <scope>test</scope>
</dependency>
Ossetic answered 11/8, 2012 at 18:44 Comment(1)
It solves the “org.slf4j.impl.StaticLoggerBinder” error, but now is logging everything, i put log4j.xml and log4j.properties (one at a time) in src/test/resources, now all frameworks in my project are logging tons of messages except my own loggings.Geometer
I
5

Had similar error with the same result with Gradle and was able to solve it by following:

//compile 'org.slf4j:slf4j-api:1.7.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.1'

Out-commented line is the one which caused the error output. I believe you can transfer this to Maven.

Innsbruck answered 29/10, 2014 at 15:11 Comment(0)
T
3

You haven't specify version in your maven dependency file may be thats why it is not picking the latest jar
As well as you need another deppendency with slf4j-log4j12 artifact id.
Include this in your pom file

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

Let me know if error is still not resolved
I also recomend you to see this link

Thomas answered 14/8, 2012 at 11:7 Comment(2)
All the versions stated were checked. I didnt declare it there in order to avoid repetition. The tag left empty intentionally. Please see that the above issue was posted as a bug to m2e support site and there is no way to resolve the above error unless is supressed by the m2e developers. I have read the website numerous times and i included all possible libraries that could resolve the issue. Unfortunately none configuration worked because it has to do with m2e rather than the declared dependencies. The above error does not show in maven console or Netbeans.ONLY in Eclipse.Overcheck
slf4j-log4j12 is another binding along with slf4j-simple, slf4j-jdk14 and logback-classic. Any of the above dependencies should have resolved the issue with the binding. As i explained earlier the problem is with m2e. Thanks anyway.Overcheck
G
1

Had been over looking the issue having surfaced it. Believe this will be a good read for others who come down here with the same issue:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=387064

Gamb answered 30/7, 2014 at 5:33 Comment(3)
please provide a full answer, not just a link.Unexpressive
@Gamb If you read the question description you can find a part which says "For viewing the above bug please refer to m2e official support site" which points to the url that you have mentioned.Overcheck
Oops.. My bad. Sincere apologies!Gamb
M
0

I had the similar issue for my Spring Boot - Gradle application running on Eclipse Luna. I could resolve it by manually adding an entry in my project's .classpath

<classpathentry sourcepath="C:/Users/<username>/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.7/3150039466ad03e6ef1c7ec1c2cbb0d96710cf64/slf4j-simple-1.7.7-sources.jar" kind="lib" path="C:/Users/<username>/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.7/8095d0b9f7e0a9cd79a663c740e0f8fb31d0e2c8/slf4j-simple-1.7.7.jar"/>

Idea is to follow this solution. But how to implement is dependent on case to case. One way of fixing is the one that I used above.

Hope this helps.

Muldrow answered 5/8, 2015 at 10:44 Comment(0)
A
0

I had the same problem in writing the Kafka producer program using java. This error is coming due to the wrong slf4j library. use below slf4j-simple maven dependency that will fix your problem.

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.6.1</version>
    <scope>test</scope>
</dependency>
Akanke answered 16/12, 2019 at 5:39 Comment(0)
S
0

I had same problem. I solved it with this way. Add this dependencies to maven "pom.xml" and reload maven. than try to run your code.
` org.slf4j slf4j-nop 2.0.0-alpha5 test

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>2.0.0-alpha5</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>2.0.0-alpha5</version>
    </dependency>`
Salman answered 3/12, 2021 at 8:29 Comment(0)
S
0
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-nop</artifactId>
        <version>2.0.0-alpha5</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>2.0.0-alpha5</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>2.0.0-alpha5</version>
    </dependency>
Salman answered 3/12, 2021 at 8:32 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Devy
H
-1

This is not an error message but a warning. It is very clearly explained in their website as :

This warning, i.e. not an error, message is reported when no SLF4J providers 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. Note that these providers must target slf4j-api 1.8 or later.

In the absence of a provider, SLF4J will default to a no-operation (NOP) logger provider.

https://www.slf4j.org/codes.html#StaticLoggerBinder

Heroine answered 16/5, 2018 at 19:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.