Hi Olivier. On 25.05.2010, at 10:53, Olivier Bourdon wrote:
> Hello everyone > > let's assume that my Java code is using several different 3rd parties > libraries (Hibernate, Jersey and some others) which > use "potentially unknown" logging mechanisms (java standard logging or > log4j). How will slf4j behave in this case as > I know I can not use more than 1 binding ? Do I need any special > configuration file settings ? > You'd use one binding - I'd suggest Logback - and bridge all other logging frameworks to SLF4J. I can only explain a bit for maven. In the 3rd-party dependency that is using one of the bridged frameworks, exclude it in your pom file, e.g. like this: <dependency> <groupId>commons-cli</groupId> <artifactId>commons-cli</artifactId> <version>1.2</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> You can do so either in the pom of your application or in the <dependencyManagement>-part of your parent pom. Doing just this would result in a ClassNotFoundException during runtime so you have to add the bridging jar manually to your application. For commons-logging, this is: <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>${slf4jVersion}</version> </dependency> You need to check all dependencies of your application for left-over dependencies, though, so no dependency is still including commons-logging. mvn dependency:tree is incredibly helpful concerning this. Do the same for any log4j-dependency and use <dependency> <groupId>org.slf4j</groupId> <artifactId>log4j-over-slf4j</artifactId> <version>${slf4jVersion}</version> </dependency> instead. Bridging jul to SLF4J is a bit more complex since the original implementation can't be swapped out since they are contained in the java-package. Take a look at http://www.slf4j.org/legacy.html <shameless-plug> And while you get happy with SLF4J and Logback, be sure to take a look at Lilith, too. http://lilith.huxhorn.de </shameless-plug> Cheers, Joern. _______________________________________________ slf4j-user mailing list slf4j-user@qos.ch http://qos.ch/mailman/listinfo/slf4j-user