[logback-user] Log4j over SLF4J using Maven = woe

Maciek Starzyk mstarzyk at gmail.com
Fri Feb 29 15:30:21 CET 2008



Jonny Cavell wrote:
> 
> The instructions for the log4j bridge (see
> http://www.slf4j.org/log4j-over-slf4j.html) say "In most situtations,
> replacing a jar file is all it takes in order to migrate from log4j to
> SLF4J.". The problem is that by using Maven I can only add
> log4j-over-slf4j; I can't remove log4j.jar because other dependencies
> (e.g. Spring) are dependent upon it. This means that things such as Spring
> etc. are all still attempting to log using JCL and log4j.
> 
> Any suggestions anybody?
> 

You can exclude some transitive dependencies in maven. You should add the
<exclusions/> element to your dependency in pom.xml like this:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>2.5.1</version>
    <exclusions>
        <exclusion>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>

However, there is no way in maven to do a "global" exclude, so you need to
repeat that for each dependency that depends on log4j, or do some hacks like
described here (for commons logging): http://tinyurl.com/2kds3v

Cheers, 
Maciek
-- 
View this message in context: http://www.nabble.com/Log4j-over-SLF4J-using-Maven-%3D-woe-tp15717589p15759350.html
Sent from the Logback User mailing list archive at Nabble.com.




More information about the Logback-user mailing list