Log4j 1.2 is broken on Java 9 - Java Logging



Log4j 1 has had a good run. First released in 1999, it is still widely used in a variety of Java-based projects. With Java 9, that is likely to come to an end: Log4j 1.2 is broken on Java 9. Essentially the MDC depends on the Java version string, which does not play well with Java 9’s new version-string format.

The Apache Logging PMC announced in August 2015 that Log4j 1 reached End Of Life and there would be no further releases. The announcement encouraged users to upgrade to its successor, Log4j 2.

What does this mean, concretely? Most of Log4j 1.2 will still work on Java 9. The issue described above is with the MDC (what is now called the ThreadContext map). If you don’t use the MDC you may not be impacted, and even if you are impacted this workaround may help.

What has changed is that doing nothing is no longer the safest option. You could endeavor to continue using Log4j 1.2 even on Java 9, but why would you?


References: 

  1. http://mail.openjdk.java.net/pipermail/jigsaw-dev/2016-July/008654.html
  2. https://blogs.apache.org/logging/entry/moving_on_to_log4j_2