2.5 (2015-12-06)

This is the ninth GA release. It contains several bugfixes and new features. The new features include the ability to specify delete actions during file rollover, a CRON-based triggering policy for file rollover, support for JSR 223 scripts in filters, pattern selectors and delete actions, and a policy for removing idle appenders from the RoutingAppender. More details on the features and bugfixes are itemized below.

Log4j 2.5 requires a minimum of Java 7 to build and run. Log4j 2.3 was the last release that supported 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 support for JSR 223 scripts in filters and the PatternSelector. (for LOG4J2-1136 by Ralph Goers)

  • Add getters for source and destination file in file rename action. (for LOG4J2-1168 by Gary Gregory, Steven Swor)

  • Add getters for classes in org.apache.logging.log4j.core.appender.rolling.action. (for LOG4J2-1175 by Gary Gregory)

  • Support use-case for JDBC’s CommonDataSource.setLogWriter(PrintWriter) and java.sql.DriverManager.setLogWriter(PrintWriter). (for LOG4J2-1178 by Gary Gregory)

  • Support use case for java.sql.DriverManager.setLogStream(PrintStream). (for LOG4J2-1187 by Gary Gregory)

  • Added support for custom delete actions triggered by a rollover. (for LOG4J2-435 by Remko Popma, Robert Schaft)

  • Added system property to allow users to control whether messages should be formatted in the background. (for LOG4J2-898 by Remko Popma)

  • Allow rollover to occur at any time. Add CronTriggeringPolicy. (for LOG4J2-89 by Ralph Goers)

Changed

  • Update Jackson from 2.6.2 to 2.6.3. (for LOG4J2-1174 by Gary Gregory)

  • Remove ConfigurationMonitor. The WatchManager is now used to check for configuration changes. (for LOG4J2-1202 by Ralph Goers)

  • Update kafka-clients from 0.8.2.2 to 0.9.0.0. (for LOG4J2-1207 by Gary Gregory)

  • Add PurgePolicy and IdlePurgePolicy to RoutingAppender. (for LOG4J2-649 by Ralph Goers, Aleksey Zvolinsky)

Fixed

  • Performance improvement when gathering location information. (for LOG4J2-1029 by Remko Popma, Stefan Leonhartsberger)

  • Web site corrections and updates. (for LOG4J2-1156 by Remko Popma)

  • Fix compilation error for classes annotated with @Plugin. (for LOG4J2-1157 by Matt Sicker, Norbert Bartels)

  • Log4J JUL adapter is using MessageFormat on String passed by java.util.function.Supplier<String>. (for LOG4J2-1158 by Gary Gregory, Michael Fortin)

  • Fixed a ThreadLocal memory leak in Tomcat8 that mentions AsyncLoggers when Async Loggers are not used. (for LOG4J2-1159 by Remko Popma)

  • Improve Log4j initialization status messages. (for LOG4J2-1165 by Remko Popma)

  • AbstractConfiguration executor should use a DaemonThreadFactory. (for LOG4J2-1166 by Remko Popma)

  • Use servlet context name for logger context name when available. (for LOG4J2-1171 by Remko Popma)

  • Fixed ThreadLocal leak [AsyncLogger$Info] on Tomcat when using AsyncLoggerContextSelector. (for LOG4J2-1172 by Remko Popma)

  • Fixed rollover error when copying to a directory mapped to a remote Linux host. (for LOG4J2-1173 by Remko Popma)

  • Fixed memory leak when log4j jars are in Tomcat’s lib folder. (for LOG4J2-1176 by Remko Popma)

  • Logger cache does not account for message factory. (for LOG4J2-1180 by Gary Gregory, Mikael Ståldal)

  • Prefix all thread names Log4j creates with "Log4j2-". (for LOG4J2-1193 by Gary Gregory)

  • Documentation does not match parameters for LoggerNameLevelRewritePolicy. (for LOG4J2-1194 by Gary Gregory, Adam Brin)

  • Make KafkaAppender support SerializedLayout. (for LOG4J2-1195 by Mikael Ståldal, Melvin Du)

  • MongoDbConnection does not close MongoClient. (for LOG4J2-1196 by Matt Sicker, René Zanner)

  • Better web app support for async loggers: Fixed a memory leak that occurred when the logging jars are placed in the container’s classpath and the configuration file uses AsyncRoot/AsyncLogger. The problem was that the first web application started the Disruptor background thread [AsyncLoggerConfig-1] but did not stop it until all web apps are stopped. Each web application now has its own Disruptor which is stopped/started together with the web app. (for LOG4J2-323 by Remko Popma)

  • Reduced memory usage of status messages in bounded queue; support zero-length queue that stores no messages. (for LOG4J2-324 by Remko Popma)

  • Allow triggering policy and rollover strategy to be modified during reconfiguration. (for LOG4J2-381 by Ralph Goers, Anthony Baldocchi)

  • Better web app support for async loggers: it is now possible to place the logging jars in the container’s classpath when making all loggers asynchronous by using AsyncLoggerContextSelector. This fixes a problem where logging would stop working after stopping and restarting a web application. (for LOG4J2-493 by Remko Popma)

  • org.apache.logging.log4j.core.Logger should be serializable. (for LOG4J2-801 by Matt Sicker)

  • Fixed bug where omitting the <display-name> element in web.xml caused incorrect log4j initialization, resulting in memory leaks when the web application was stopped or reloaded. (for LOG4J2-873 by Remko Popma, Martin Dickins, LC, Luke Woodward)

  • Documentation: fixed minor issues with the site and manual pages. (for LOG4J2-879 by Remko Popma)

  • Fix plugin documentation error about Converters. (for LOG4J2-948 by Matt Sicker, Andrew Flower)

  • RollingFileAppender should also roll over when log event time is equal to rollover time, not only when later. (for LOG4J2-999 by Remko Popma, Joan Balagueró)