2.4

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.

Added

  • Add a way to route messages based on the %marker in Layout for RoutingAppender. (LOG4J2-1015)

  • New RewritePolicy for changing level of a log event. (LOG4J2-1023)

  • Add a Log4jLookup class to help write log files relative to log4j2.xml. (LOG4J2-1050)

  • Add API org.apache.logging.log4j.LogManager.getFormatterLogger(). (LOG4J2-1057)

  • Expose Log4jContextFactory’s ShutdownCallbackRegistry. (LOG4J2-1066)

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

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

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

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

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

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

  • Add a LevelRangeFilter class. (LOG4J2-1106)

  • New Appender for Apache Kafka. (LOG4J2-1107)

  • New publisher Appender for ZeroMQ (using JeroMQ). (LOG4J2-1113)

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

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

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

  • New module for Liquibase integration. (LOG4J2-767)

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

Changed

  • Pass log event when interpolating logger properties. (LOG4J2-1010)

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

  • Update database tests from H2 1.3.175 to 1.3.176. (LOG4J2-1018)

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

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

  • Update Apache Flume from 1.5.2 to 1.6.0. (LOG4J2-1036)

  • Update MongoDB driver from 2.11.2 to 2.13.2. (LOG4J2-1041)

  • Support batchSize in FlumeAvroManager. (LOG4J2-1044)

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

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

  • Update Java Mail from 1.5.2 to 1.5.4. (LOG4J2-1070)

  • Update Jackson from 2.5.3 to 2.5.4. (LOG4J2-1079)

  • Update Jackson from 2.6.0 to 2.6.1. (LOG4J2-1092)

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

  • 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. (LOG4J2-1097)

  • Update Apache Commons Compress from 1.9 to 1.10. (LOG4J2-1104)

  • Add thread name to status logger layout. (LOG4J2-1114)

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

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

  • Update Jackson from 2.5.4 to 2.6.0. (LOG4J2-1879)

  • MongoDB appender, username and password should be optional. (LOG4J2-403)

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

  • log4j-web-2.1 should work around a bug in JBOSS EAP 6.2. (LOG4J2-890)

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

Fixed

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

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

  • Custom java.util.logging.Level gives null Log4j Level and causes NPE. (LOG4J2-1025)

  • HighlightConverter does not obey noConsoleNoAnsi. (LOG4J2-1026)

  • SimpleLogger creates unnecessary Map objects by calling ThreadContext.getContext() instead of getImmutableContext(). (LOG4J2-1033)

  • Backward compatibility issue in log4j-1.2-api NDC pop() and peek(). (LOG4J2-1037)

  • Incorrect documentation for layout default charset. (LOG4J2-1038)

  • Socket and Syslog appenders don’t take timeout into account at startup. (LOG4J2-1042)

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

  • Externalize log4j2.xml via URL resource. (LOG4J2-1045)

  • Circular Exception cause throws StackOverflowError. (LOG4J2-1046)

  • FileConfigurationMonitor unnecessarily calls System.currentTimeMillis() causing high CPU usage. (LOG4J2-1048)

  • AsyncAppender now resets the thread interrupted flag after catching InterruptedException. (LOG4J2-1049)

  • NoClassDefFoundError when starting app on Google App Engine. (LOG4J2-1051)

  • Log4jMarker#contains(String) does not respect org.slf4j.Marker contract. (LOG4J2-1058)

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

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

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

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

  • ThrowableProxy getExtendedStackTraceAsString throws NPE on deserialized nested exceptions. (LOG4J2-1067)

  • Exceptions not logged when using TcpSocketServer + SerializedLayout. (LOG4J2-1068)

  • Improper handling of JSON escape chars when deserializing JSON log events. (LOG4J2-1069)

  • GelfLayout throws exception if some log event fields are null. (LOG4J2-1078)

  • Misleading StatusLogger WARN event in LogManager with java.util.Map. (LOG4J2-1084)

  • NullPointerException when passing null to java.util.logging.Logger.setLevel(). (LOG4J2-1108)

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

  • OutputStreamManager in ConsoleAppender leaking managers. (LOG4J2-1117)

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

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

  • ExtendedThrowablePatternConverter does not print suppressed exceptions. (LOG4J2-684)

  • Header in layout should not be written on application startup if appending to an existing file. Fixes LOG4J2-1030. (LOG4J2-889)

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

  • Circular suppressed Exception throws StackOverflowError. (LOG4J2-934)

  • Use System.nanoTime() to measure time intervals. (LOG4J2-982)

Removed

  • Removed experimental interface LevelLogger which got committed to master by mistake.