2.4 (2015-09-20)

This is the eighth GA release. It contains several bugfixes and new features. As of this release Log4j now requires a minimum of Java 7.

Apache Log4j 2.4 requires a minimum of Java 7 to build and run. Log4j 2.4 and greater requires Java 7, version 2.3 required Java 6.

Basic compatibility with Log4j 1.x is provided through the log4j-1.2-api component, however it does not implement some of the very implementation specific classes and methods. The package names and Maven groupId have been changed to org.apache.logging.log4j to avoid any conflicts with Log4j 1.x.

For complete information on Apache Log4j 2, including instructions on how to submit bug reports, patches, or suggestions for improvement, see the Apache Log4j 2 website.

Changes

Added

  • Add a way to route messages based on the %marker in Layout for RoutingAppender. (for LOG4J2-1015 by Gary Gregory, Daniel Marcotte)

  • New RewritePolicy for changing level of a log event. (for LOG4J2-1023 by Gary Gregory, Mikael Ståldal)

  • Add a Log4jLookup class to help write log files relative to log4j2.xml. (for LOG4J2-1050 by Gary Gregory, Adam Retter)

  • Add API org.apache.logging.log4j.LogManager.getFormatterLogger(). (for LOG4J2-1057 by Gary Gregory)

  • Expose Log4jContextFactory’s ShutdownCallbackRegistry. (for LOG4J2-1066 by Gary Gregory, Charles Allen)

  • Added support for system nanosecond time in pattern layout. (for LOG4J2-1074 by Remko Popma)

  • Added support for compressing to bzip2 format on file rollover. (for LOG4J2-1075 by Remko Popma)

  • Support additional Apache Commons Compress compression formats on rollover: Deflate, Pack200, XY. (for LOG4J2-1077 by Gary Gregory)

  • Add Comma Separated Value (CSV) layouts for parameter and event logging. (for LOG4J2-1088 by Gary Gregory)

  • Add Core Configurator APIs to change a logger’s level. (for LOG4J2-1090 by Gary Gregory)

  • Add API org.apache.logging.log4j.Level.isInRange(Level, Level). (for LOG4J2-1105 by Gary Gregory, Gary Gregory)

  • Add a LevelRangeFilter class. (for LOG4J2-1106 by Gary Gregory, Gary Gregory)

  • New Appender for Apache Kafka. (for LOG4J2-1107 by Gary Gregory, Mikael Ståldal)

  • New publisher Appender for ZeroMQ (using JeroMQ). (for LOG4J2-1113 by Gary Gregory, Gary Gregory)

  • Updated Logger wrapper generator tool to add Java 8 lambda support for custom log levels. (for LOG4J2-1118 by Remko Popma)

  • Added support for Java 8 lambda expressions to lazily construct a log message only if the requested log level is enabled. (for LOG4J2-599 by Remko Popma)

  • Add support for configuration via Properties. (for LOG4J2-635 by Ralph Goers)

  • New module for Liquibase integration. (for LOG4J2-767 by Gary Gregory, Mikael Ståldal)

  • Add ConfigurationBuilder for programmatic configuration. (for LOG4J2-952 by Ralph Goers)

Changed

  • Pass log event when interpolating logger properties. (for LOG4J2-1010 by Ralph Goers)

  • Update Java platform from Java 6 to 7. From this version onwards, log4j 2 requires Java 7. (for LOG4J2-1017 by Gary Gregory)

  • Update database tests from H2 1.3.175 to 1.3.176. (for LOG4J2-1018 by Gary Gregory)

  • Allow a list of keys to be specified in the MDC pattern converter. (for LOG4J2-1022 by Ralph Goers)

  • Log4j2 tries to SystemClassLoader when running on Google AppEngine. (for LOG4J2-1035 by Gary Gregory)

  • Update Apache Flume from 1.5.2 to 1.6.0. (for LOG4J2-1036 by Gary Gregory)

  • Update MongoDB driver from 2.11.2 to 2.13.2. (for LOG4J2-1041 by Gary Gregory)

  • Support batchSize in FlumeAvroManager. (for LOG4J2-1044 by Ralph Goers)

  • Avoid creating temporary array object in org.apache.logging.slf4j.Log4jMarker.iterator(). (for LOG4J2-1063 by Gary Gregory)

  • Define org.apache.logging.log4j.Marker.equals(Object) and org.apache.logging.log4j.Marker.hashCode(). (for LOG4J2-1065 by Gary Gregory)

  • Update Java Mail from 1.5.2 to 1.5.4. (for LOG4J2-1070 by Gary Gregory)

  • Update Jackson from 2.5.3 to 2.5.4. (for LOG4J2-1079 by Gary Gregory)

  • Update Jackson from 2.6.0 to 2.6.1. (for LOG4J2-1092 by Gary Gregory)

  • Improved performance of ParameterizedMessage::getFormattedMessage by ~2X. (for LOG4J2-1096 by Remko Popma)

  • PatternLayout timestamp formatting performance improvement: predefined date formats (and variants using a period '.' millisecond separator instead of ',') are now formatted ~2-10X faster than other date formats. (for LOG4J2-1097 by Remko Popma)

  • Update Apache Commons Compress from 1.9 to 1.10. (for LOG4J2-1104 by Gary Gregory)

  • Add thread name to status logger layout. (for LOG4J2-1114 by Gary Gregory)

  • LoggerConfig performance improvements: avoid unnecessary lock acquisition, use more efficient data structure. (for LOG4J2-1120 by Remko Popma)

  • PatternLayout performance improvement by caching and reusing a ThreadLocal StringBuilder. (for LOG4J2-1125 by Remko Popma)

  • Update Jackson from 2.5.4 to 2.6.0. (for LOG4J2-1879 by Gary Gregory)

  • MongoDB appender, username and password should be optional. (for LOG4J2-403 by Gary Gregory, Poorna Subhash P, Jeremy Lautman)

  • PatternLayout timestamp formatting performance improvement: replaced synchronized SimpleDateFormat with Apache Commons FastDateFormat. This and better caching resulted in a ~3-30X faster timestamp formatting. (for LOG4J2-812 by Ralph Goers)

  • log4j-web-2.1 should work around a bug in JBOSS EAP 6.2. (for LOG4J2-890 by Gary Gregory, Remko Popma, Hassan Kalaldeh, Robert Andersson)

  • Fix FindBugs DM_DEFAULT_ENCODING bug in SimpleLogger.logMessage() and simplify code. (for LOG4J2-959 by Gary Gregory)

Removed

  • Removed experimental interface LevelLogger which got committed to master by mistake. (for by Remko Popma)

Fixed

  • ZipCompressAction leaves files open until GC when an IO error takes place. (for LOG4J2-1019 by Gary Gregory)

  • GzCompressAction leaves files open until GC when an IO error takes place. (for LOG4J2-1020 by Gary Gregory)

  • Custom java.util.logging.Level gives null Log4j Level and causes NPE. (for LOG4J2-1025 by Gary Gregory, Mikael Ståldal)

  • HighlightConverter does not obey noConsoleNoAnsi. (for LOG4J2-1026 by Gary Gregory)

  • SimpleLogger creates unnecessary Map objects by calling ThreadContext.getContext() instead of getImmutableContext(). (for LOG4J2-1033 by Gary Gregory, Mikael Ståldal)

  • Backward compatibility issue in log4j-1.2-api NDC pop() and peek(). (for LOG4J2-1037 by Gary Gregory, Marc Dergacz)

  • Incorrect documentation for layout default charset. (for LOG4J2-1038 by Gary Gregory, Gili)

  • Socket and Syslog appenders don’t take timeout into account at startup. (for LOG4J2-1042 by Gary Gregory, Guillaume Turri)

  • Write pending events to Flume when the appender is stopped. (for LOG4J2-1044 by Ralph Goers)

  • Externalize log4j2.xml via URL resource. (for LOG4J2-1045 by Gary Gregory, Günter Albrecht)

  • Circular Exception cause throws StackOverflowError. (for LOG4J2-1046 by Gary Gregory, Kenneth Gendron)

  • FileConfigurationMonitor unnecessarily calls System.currentTimeMillis() causing high CPU usage. (for LOG4J2-1048 by Remko Popma, Nikhil)

  • AsyncAppender now resets the thread interrupted flag after catching InterruptedException. (for LOG4J2-1049 by Remko Popma, Robert Schaft)

  • NoClassDefFoundError when starting app on Google App Engine. (for LOG4J2-1051 by Gary Gregory, Lukasz Lenart)

  • Log4jMarker#contains(String) does not respect org.slf4j.Marker contract. (for LOG4J2-1058 by Gary Gregory, Daniel Branzea)

  • Log4jMarker#contains(Marker) does not respect org.slf4j.Marker contract. (for LOG4J2-1060 by Gary Gregory)

  • Log4jMarker#remove(Marker) does not respect org.slf4j.Marker contract. (for LOG4J2-1061 by Gary Gregory)

  • Log4jMarker#add(Marker) does not respect org.slf4j.Marker contract. (for LOG4J2-1062 by Gary Gregory)

  • org.apache.logging.slf4j.Log4jMarker does not implement org.slf4j.Marker.equals(Object) org.slf4j.Marker.hashCode(). (for LOG4J2-1064 by Gary Gregory)

  • ThrowableProxy getExtendedStackTraceAsString throws NPE on deserialized nested exceptions. (for LOG4J2-1067 by Gary Gregory, Sam Braam)

  • Exceptions not logged when using TcpSocketServer + SerializedLayout. (for LOG4J2-1068 by Gary Gregory, Andy McMullan)

  • Improper handling of JSON escape chars when deserializing JSON log events. (for LOG4J2-1069 by Gary Gregory, Sam Braam)

  • GelfLayout throws exception if some log event fields are null. (for LOG4J2-1078 by Gary Gregory, Mikael Ståldal)

  • Misleading StatusLogger WARN event in LogManager with java.util.Map. (for LOG4J2-1084 by Gary Gregory, Philipp Schneider)

  • NullPointerException when passing null to java.util.logging.Logger.setLevel(). (for LOG4J2-1108 by Gary Gregory, Mikael Ståldal)

  • org.apache.logging.log4j.jul.CoreLogger.setLevel() checks for security permission too late. (for LOG4J2-1110 by Gary Gregory)

  • OutputStreamManager in ConsoleAppender leaking managers. (for LOG4J2-1117 by Gary Gregory, Marcus Thiesen)

  • Fixed potential race condition on reconfiguration. Introduced ReliabilityStrategy to facilitate switching between different mechanisms for preventing log events from being dropped on reconfiguration. (for LOG4J2-1121 by Remko Popma)

  • Core Configurator.initialize(String, ClassLoader, String) fails to work when config location is a file path. (for LOG4J2-1123 by Gary Gregory)

  • ExtendedThrowablePatternConverter does not print suppressed exceptions. (for LOG4J2-684 by Gary Gregory, Joern Huxhorn, Mauro Molinari)

  • Header in layout should not be written on application startup if appending to an existing file. Fixes LOG4J2-1030. (for LOG4J2-889 by Remko Popma, Maciej Karaś, Kenneth Leider)

  • Clarify documentation for combining async with sync loggers. (for LOG4J2-918 by Remko Popma)

  • Circular suppressed Exception throws StackOverflowError. (for LOG4J2-934 by Gary Gregory, Kenneth Gendron)

  • Use System.nanoTime() to measure time intervals. (for LOG4J2-982 by Gary Gregory, Mikhail Mazurskiy)