Hibernate, Spring and SLF4J Binding

This should indeed work, the slf4j-log4j12 binding contains org/slf4j/impl/StaticLoggerBinder.

  1. Try to clean and redeploy your application, maybe something went wrong during deployment.
  2. Double check that the downloaded slf4j-log4j12-1.5.8.jar is not corrupted (try to open it).
  3. Maybe even delete it and let maven re-download it.

Some unrelated remarks:

  • Instead of repeating frameworks version in dependencies, you should use a property. For example:

    ...
    <properties>
      <spring.version>3.0.2.RELEASE</spring.version>
      ...
    </properties>
    <dependencies>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
      </dependency>
      ...
    </dependencies>
    
  • hibernate-core is a transitive dependency of hibernate-annotations, you don't need to declare it (if you want to use JPA, you should actually depend on hibernate-entitymanager).


Include the slf4j-api in your dependencies:

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

Exclude the commons-logging dependency for minimum one of your declared spring dependencies and provide the slf4j facade for commons-logging:

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>3.0.2.RELEASE</version>
  <exclusions>
     <exclusion>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
     </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>jcl-over-slf4j</artifactId>
  <version>1.5.8</version>
  <scope>runtime</scope>
</dependency>

Include the log4j dependency for your logging together with the slf4j facade:

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
  <version>1.5.8</version>
  <scope>runtime</scope>
</dependency>
<dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.14</version>
  <scope>runtime</scope>
</dependency>

A great blog post for further reading about logging with SLF4J and Spring can be found in the SpringSource Team blog under http://blog.springsource.com/2009/12/04/logging-dependencies-in-spring/.