Search code examples
log4jlog4j2

Difference between slf4j-log4j12 and log4j-slf4j-impl


In some projects which used slf4j and log4j I can see dependencies like

compile('org.apache.logging.log4j:log4j-core:version')
compile('org.apache.logging.log4j:log4j-api:version')
compile('org.apache.logging.log4j:log4j-slf4j-impl:version')

But some projects use slf4j-log4j12 instead of log4j-slf4j-impl. To my understanding they are both works like bridges between slf4j and log4j, but what's their difference?


Solution

  • Those artifacts use different versions of Log4j:

    • slf4j-log4j12 is a bridge between SLF4J and Log4j 1.2. Its versioning follows SLF4J.
    • slf4j-reload4j is a bridge between SLF4J and Reload4j (a clone of Log4j 1.2). Its versioning follows SLF4J.
    • log4j-slf4j-impl is a bridge between SLF4J 1 (up to 1.7.x) and Log4j 2 API. Its versioning follows LOG4J2.
    • log4j-slf4j2-impl is a bridge between SLF4J 2 (or higher) and Log4j 2 API. Its versioning follows LOG4J2.

    Since Log4j 1.x reached end-of-life in 2015, there is no sense in using the first one in new software.