Search code examples
log4jlog4j2

log4j "bridge" and the RootLogger class


We're trying to force an old vendor-provided Java-program (a JAR) to use log4j2, with the help of the log4j "bridge".

To do this, I:

  • Deleted all entries starting with org/apache/log4j/* from the vendor's JAR
  • Added the log4j-1.2-api-2.17.1.jar and the regular log4j-*-2.17.1.jar files to CLASSPATH

The program dies unable to find the org/apache/log4j/spi/RootLogger. Listing the contents of the bridge JAR, I find several classes under the org/apache/log4j/spi/, but the RootLogger is, indeed, missing.

How do I deal with this?


Solution

  • The newest version 2.17.2 of Log4j2 contains a couple of dozen of fixes to the Log4j 1.x bridge (cf. changelog).

    Among them the org.apache.log4j.RootLogger class has been added to provide binary compatibility with Log4j 1.x.

    Warning: many of the added classes are no-ops and just prevent ClassNotFoundExceptions as the one in your question.