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

Ceki Gülcü ceki at qos.ch
Mon Nov 8 20:49:56 CET 2010


There are several waays to make logback, spring and slf4j to work 
together. Here is the simplest maven dependency declaration which is 
known to work nicely.

<dependencies>
    <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-context</artifactId>
       <version>3.0.0.RELEASE</version>
    <dependency>

    <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
       <version>1.1.1</version>
       <scope>provided</scope>
    <dependency>

   <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.6.1</version>
    </dependency>
<dependencies>

HTH,

On 08/11/2010 8:32 PM, Seamus Hannan wrote:
> 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>
>
>
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user



More information about the Logback-user mailing list