[logback-user] Query re. LOGBack, Spring & SLF4J

Seamus Hannan seamus.hannan at gmail.com
Mon Nov 8 20:32:22 CET 2010


Hi,

I have a question concerning getting LOGBack working with Spring using
Maven.

According to the Spring Documentation Spring needs to be forced to work iwth
SLF4J. (sample code below)

My question is how do I  get LOGBack to work with this configuration
(instead of log4j)?

The Spring documentation indicates that you need to use jcl-over-slf4j, but
it is not clear how to configure LOGBack to work with Spring and SLF4J.

My code, including the example code below builds for me intermiitently from
the command line, indicating that there is some classloading issue.

Any advice will be much appreciated.

Thanks.
Seamus Hannan

<dependencies>
   <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>3.0.0.RELEASE</version>
      <scope>runtime</scope>
      <exclusions>
         <exclusion>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
         </exclusion>
      </exclusions>
   </dependency>
</dependencies>

<dependencies>
   <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>3.0.0.RELEASE</version>
      <scope>runtime</scope>
      <exclusions>
         <exclusion>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
         </exclusion>
      </exclusions>
   </dependency>

   <!-- LOGBack dependendecy required for ViewLastLog.java -->
   <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>0.9.26</version>
   </dependency>

   <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
      <version>1.5.8</version>
      <scope>runtime</scope>
   </dependency>
   <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.5.8</version>
      <scope>runtime</scope>
   </dependency>
   <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>
</dependencies>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/logback-user/attachments/20101108/0737956d/attachment.html>


More information about the Logback-user mailing list