Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". in a Maven Project [duplicate]

I have a dependency for SLF4J. I am getting this 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. 

Here is my maven entry:

    <dependency>         <groupId>org.slf4j</groupId>         <artifactId>slf4j-api</artifactId>         <version>1.6.6</version>     </dependency>      <dependency>         <groupId>org.slf4j</groupId>         <artifactId>slf4j-log4j12</artifactId>         <version>1.6.6</version>     </dependency>     <dependency>         <groupId>log4j</groupId>         <artifactId>log4j</artifactId>         <version>1.2.16</version>     </dependency> 

Where is the problem?


EDIT: Without log4j dependency I get the following exception

Failed to instantiate SLF4J LoggerFactory Reported exception: java.lang.NoClassDefFoundError: org.slf4j.impl.StaticLoggerBinder     at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)     at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)     at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:268)     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:241)     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:254)     at org.apache.bval.jsr303.ConfigurationImpl.<clinit>(ConfigurationImpl.java:50)     at java.lang.J9VMInternals.initializeImpl(Native Method)     at java.lang.J9VMInternals.initialize(J9VMInternals.java:228)     at org.apache.bval.jsr303.ApacheValidationProvider.createGenericConfiguration(ApacheValidationProvider.java:66)     at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:173)     at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:50)     at com.daimler.zv9.basic.entity.AbstractEntity.<clinit>(AbstractEntity.java:73)     at java.lang.J9VMInternals.initializeImpl(Native Method)     at java.lang.J9VMInternals.initialize(J9VMInternals.java:228)     at java.lang.J9VMInternals.initialize(J9VMInternals.java:195)     at java.lang.Class.forNameImpl(Native Method)     at java.lang.Class.forName(Class.java:168) 

EDIT2: It is an example MAVEN Tree that I get

[INFO] com.myCompany.abc:ABC_Document:ejb:0.0.1-SNAPSHOT [INFO] +- com.myCompany.abc:ABC_Basic:jar:0.0.1-SNAPSHOT:compile [INFO] +- com.myCompany.iap:javax.j2ee:jar:5.0.0:provided [INFO] +- com.myCompany.iap:logging:jar:5.0.0:provided [INFO] +- com.myCompany.iap:util:jar:5.0.0:provided [INFO] +- junit:junit:jar:4.8.2:test [INFO] +- javax.servlet:jstl:jar:1.2:provided [INFO] +- org.slf4j:slf4j-api:jar:1.6.6:compile [INFO] +- org.slf4j:slf4j-simple:jar:1.6.6:compile [INFO] \- org.mockito:mockito-all:jar:1.9.0:test 
like image 212
Kayser Avatar asked Sep 17 '12 11:09

Kayser


People also ask

What is SLF4J API used for?

The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java. util. logging, logback, log4j) allowing the end user to plug in the desired logging framework at deployment time.

What is SLF4J API jar?

SLF4J API ModuleAPI for SLF4J (The Simple Logging Facade for Java) which serves as a simple facade or abstraction for various logging frameworks, allowing the end user to plug in the desired logging framework at deployment time. License.

What is static Logger binder?

public class StaticLoggerBinder extends Object. The binding of LoggerFactory class with an actual instance of ILoggerFactory is performed using information returned by this class. This class is meant to provide a dummy StaticLoggerBinder to the slf4j-api module.


1 Answers

I am assuming you are using Eclipse as your developing environment.

Eclipse Juno, Indigo and Kepler when using the bundled maven version(m2e), are not suppressing the message SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". This behaviour is present from the m2e version 1.1.0.20120530-0009 and onwards.

Although, this is indicated as an error your logs will be saved normally. The highlighted error will still be present until there is a fix of this bug. More about this in the m2e support site.

The current available solution is to use an external maven version rather than the bundled version of Eclipse. You can find about this solution and more details regarding this bug in the question below which i believe describes the same problem you are facing.

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

like image 173
Konstantinos Margaritis Avatar answered Sep 23 '22 01:09

Konstantinos Margaritis