Difference between slf4j-log4j12 and log4j-over-slf4j

JavaLog4jSlf4j

Java Problem Overview


What's the difference between slf4j-log4j12 and log4j-over-slf4j and when should each be used?

<dependency>
	<groupId>org.slf4j</groupId>
	<artifactId>slf4j-log4j12</artifactId>
	<version>1.7.12</version>
</dependency>
<dependency>
	<groupId>org.slf4j</groupId>
	<artifactId>log4j-over-slf4j</artifactId>
	<version>1.7.12</version>
</dependency>

Java Solutions


Solution 1 - Java

log4j-over-slf4j

Use this if your code or some libraries you are using uses Log4j directly, but you want to use a different SLF4J binding than Log4j. It will route the Log4j API calls to SLF4J to the binding you choose. You need to remove the Log4j library from your classpath and replace it with this dependency.

slf4j-log4j12

Use this if you want to use the Log4j 1.2 binding for SLF4J.

You shouldn't use both of these libraries at the same time.

Please note also that Log4j 2 has been released.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKumar SambhavView Question on Stackoverflow
Solution 1 - JavaPuceView Answer on Stackoverflow