Search code examples
log4jslf4j

log4j-slf4j2-impl does not include log4j-core, is this intentional?


I noticed that log4j-core has different dependency scope in the two slf4j-impl libraries.

Is this by design?

log4j-core scope
log4j-slf4j-impl runtime
log4j-slf4j2-impl test

Looks like it was changed with this commit, which references LOG4J2-2975. I don't see anything that mentions why the scope was changed from runtime to test.


Solution

  • Yes, removing the runtime dependency on log4j-core was intentional, since the log4j-slf4j2-impl module works with any implementation of the Log4j2 API.

    Since version 2.17.2 at least two implementations can be used with the SLF4J-to-LOG4J2 bridge: log4j-core and log4j-to-jul (the third implementation maintained by the Log4j2 project, log4j-to-slf4j, can not be used for obvious reasons).

    This choice was not undisputed: cf. LOG4J2 3601 for a discussion.