Maven and Spring - SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"

15,336

Solution 1

I was suffering from a similar problem. And to make matters worse Hibernate was not showing the full stacktrace of the exception.

I was using Eclipse Luna and was working on a Maven project.

After reading various answers pertaining to above issue, nothing helped until I used: 'Slf4j Maven Plugin Log' :

"A SLF4J implementation which delegates to maven-plugin logging toolkit. Especially useful when maven-plugin dependencies use slf4j, cause their logs aren't available as maven-plugin logs."

Source:http://mvnrepository.com/artifact/com.googlecode.slf4j-maven-plugin-log/slf4j-maven-plugin-log/1.0.0

Solution 2

Apparently this is a bug in the m2eclipse plugin.

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

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

Solution 3

Found this earlier today in my search for an answer. It wasn't for a long time later that I finally the answer that worked for me. This was answered for me by Spring behind the scenes logging

The jist of it is to add the following to your pom.xml:

<dependency> 
 <groupId>org.apache.logging.log4j</groupId>
 <artifactId>log4j-slf4j-impl</artifactId>
 <version>2.1</version>
</dependency> 
Share:
15,336
Chris
Author by

Chris

Updated on June 05, 2022

Comments

  • Chris
    Chris almost 2 years

    I'm building a new spring web application which uses maven for dependency management. I am trying to use slf4j-api and slf4j-simple. I added them to my pom file, but when I build I get the 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.
    

    Which is indicative of slf4j not having an implementation, however, slf4j-simple is include in my pom. Below is my pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>foo.bar</groupId>
      <artifactId>name</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>war</packaging>
      <name>name</name>
    
    
        <properties>
            <org.springframework.version>3.1.0.RELEASE</org.springframework.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${org.springframework.version}</version>
                 <exclusions>
                      <exclusion>
                          <groupId>commons-logging</groupId>
                          <artifactId>commons-logging</artifactId>
                      </exclusion>
                 </exclusions>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
                <groupId>jstl</groupId>
                <artifactId>jstl</artifactId>
                <version>1.2</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                 <version>3.6.3.Final</version>
            </dependency>
            <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-api</artifactId>
              <version>1.6.6</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <version>1.6.6</version>
            </dependency>
            <dependency>
                <groupId>net.sourceforge.jtds</groupId>
                <artifactId>jtds</artifactId>
                <version>1.2.4</version>
            </dependency>
        </dependencies>
        <build>
            <finalName>ROOT</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.5.1</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1.1</version>
                    <configuration>
                        <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>    
    

    Below is my maven dependency tree:

    [INFO] foo.bar:name:war:0.0.1-SNAPSHOT
    [INFO] +- org.springframework:spring-context:jar:3.1.0.RELEASE:compile
    [INFO] |  +- org.springframework:spring-aop:jar:3.1.0.RELEASE:compile
    [INFO] |  |  \- aopalliance:aopalliance:jar:1.0:compile
    [INFO] |  +- org.springframework:spring-beans:jar:3.1.0.RELEASE:compile
    [INFO] |  +- org.springframework:spring-core:jar:3.1.0.RELEASE:compile
    [INFO] |  +- org.springframework:spring-expression:jar:3.1.0.RELEASE:compile
    [INFO] |  \- org.springframework:spring-asm:jar:3.1.0.RELEASE:compile
    [INFO] +- org.springframework:spring-webmvc:jar:3.1.0.RELEASE:compile
    [INFO] |  +- org.springframework:spring-context-support:jar:3.1.0.RELEASE:compile
    [INFO] |  \- org.springframework:spring-web:jar:3.1.0.RELEASE:compile
    [INFO] +- jstl:jstl:jar:1.2:compile
    [INFO] +- org.hibernate:hibernate-core:jar:3.6.3.Final:compile
    [INFO] |  +- antlr:antlr:jar:2.7.6:compile
    [INFO] |  +- commons-collections:commons-collections:jar:3.1:compile
    [INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
    [INFO] |  +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
    [INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
    [INFO] |  \- javax.transaction:jta:jar:1.1:compile
    [INFO] +- org.slf4j:slf4j-api:jar:1.6.6:compile
    [INFO] +- org.slf4j:slf4j-simple:jar:1.6.6:compile
    [INFO] \- net.sourceforge.jtds:jtds:jar:1.2.4:compile
    

    Any ideas on what could be wrong? Thanks.

  • Chris
    Chris over 11 years
    I tried running maven from the command line and did not receive the error. This message seems to be a bug in the m2eclipse plugin. Thanks for your help.