Log4j 2.4 发布,这是第 8 个 GA 版本,包括一些 bug 修复和新特性。此版本最低要求 Java 7。
此版本更新内容如下:
新特性
o LOG4J2-635: Add support for configuration via Properties.
o LOG4J2-952: Add ConfigurationBuilder.
o LOG4J2-599: Added support for Java 8 lambda expressions to lazily construct a log message
only if the requested log level is enabled.
o LOG4J2-1118: Updated Logger wrapper generator tool to add Java 8 lambda support for custom
log levels.
o LOG4J2-1107: New Appender for Apache Kafka. Thanks to Mikael Ståldal.
o LOG4J2-1113: New publisher Appender for ZeroMQ (using JeroMQ). Thanks to Gary Gregory.
o LOG4J2-1088: Add Comma Separated Value (CSV) layouts for parameter and event logging. Thanks
to Gary Gregory.
o LOG4J2-1090: Add Core Configurator APIs to change a logger’s level.
o LOG4J2-1105: Add API org.apache.logging.log4j.Level.isInRange(Level, Level). Thanks to
Gary Gregory.
o LOG4J2-1106: Add a LevelRangeFilter class. Thanks to Gary Gregory.
o LOG4J2-1076: Added support for system nanosecond time in pattern layout.
o LOG4J2-1075: Added support for compressing to bzip2 format on file rollover.
o LOG4J2-1077: Support additional Apache Commons Compress compression formats on rollover:
Deflate, Pack200, XY.
o LOG4J2-767: New module for Liquibase integration. Thanks to Mikael Ståldal.
o LOG4J2-1023: New RewritePolicy for changing level of a log event. Thanks to Mikael Ståldal.
o LOG4J2-1015: Add a way to route messages based on the %marker in Layout for RoutingAppender.
Thanks to Daniel Marcotte.
o LOG4J2-1050: Add a Log4jLookup class to help write log files relative to log4j2.xml. Thanks
to Adam Retter.
o LOG4J2-1057: Add API org.apache.logging.log4j.LogManager.getFormatterLogger().
o LOG4J2-1066: Expose Log4jContextFactory’s ShutdownCallbackRegistry. Thanks to Charles Allen.
Bug 修复
o LOG4J2-1121: Fixed potential race condition on reconfiguration. Introduced ReliabilityStrategy
to facilitate switching between different mechanisms for preventing log events from being dropped
on reconfiguration.
o LOG4J2-1123: Core Configurator.initialize(String, ClassLoader, String) fails to work when
config location is a file path. Thanks to Gary Gregory.
o LOG4J2-1117: OutputStreamManager in ConsoleAppender leaking managers. Thanks to Marcus
Thiesen.
o LOG4J2-1044: Write pending events to Flume when the appender is stopped.
o LOG4J2-1108: NullPointerException when passing null to java.util.logging.Logger.setLevel().
Thanks to Mikael Ståldal.
o LOG4J2-1110: org.apache.logging.log4j.jul.CoreLogger.setLevel() checks for security permission
too late.
o LOG4J2-1084: Misleading StatusLogger WARN event in LogManager with java.util.Map. Thanks
to Philipp Schneider.
o LOG4J2-1051: NoClassDefFoundError when starting app on Google App Engine. Thanks to Lukasz
Lenart.
o LOG4J2-684: ExtendedThrowablePatternConverter does not print suppressed exceptions. Thanks
to Joern Huxhorn, Mauro Molinari.
o LOG4J2-1069: Improper handling of JSON escape chars when deserializing JSON log events.
Thanks to Sam Braam.
o LOG4J2-1068: Exceptions not logged when using TcpSocketServer + SerializedLayout. Thanks
to Andy McMullan.
o LOG4J2-1067: ThrowableProxy getExtendedStackTraceAsString throws NPE on deserialized nested
exceptions. Thanks to Sam Braam.
o LOG4J2-1049: AsyncAppender now resets the thread interrupted flag after catching InterruptedException.
Thanks to Robert Schaft.
o LOG4J2-1048: FileConfigurationMonitor unnecessarily calls System.currentTimeMillis() causing
high CPU usage. Thanks to Nikhil.
o LOG4J2-1037: Backward compatibility issue in log4j-1.2-api NDC pop() and peek(). Thanks
to Marc Dergacz.
o LOG4J2-1025: Custom java.util.logging.Level gives null Log4j Level and causes NPE. Thanks
to Mikael Ståldal.
o LOG4J2-1033: SimpleLogger creates unnecessary Map objects by calling ThreadContext.getContext()
instead of getImmutableContext(). Thanks to Mikael Ståldal.
o LOG4J2-1026: HighlightConverter does not obey noConsoleNoAnsi.
o LOG4J2-1019: ZipCompressAction leaves files open until GC when an IO error takes place.
o LOG4J2-1020: GzCompressAction leaves files open until GC when an IO error takes place.
o LOG4J2-1038: Incorrect documentation for layout default charset. Thanks to Gili.
o LOG4J2-1042: Socket and Syslog appenders don’t take timeout into account at startup. Thanks
to Guillaume Turri.
o LOG4J2-934: Circular suppressed Exception throws StackOverflowError. Thanks to Kenneth
Gendron.
o LOG4J2-1046: Circular Exception cause throws StackOverflowError. Thanks to Kenneth Gendron.
o LOG4J2-982: Use System.nanoTime() to measure time intervals. Thanks to Mikhail Mazurskiy.
o LOG4J2-1045: Externalize log4j2.xml via URL resource. Thanks to Günter Albrecht.
o LOG4J2-1058: Log4jMarker#contains(String) does not respect org.slf4j.Marker contract. Thanks
to Daniel Branzea.
o LOG4J2-1060: Log4jMarker#contains(Marker) does not respect org.slf4j.Marker contract.
o LOG4J2-1061: Log4jMarker#remove(Marker) does not respect org.slf4j.Marker contract.
o LOG4J2-1062: Log4jMarker#add(Marker) does not respect org.slf4j.Marker contract.
o LOG4J2-1064: org.apache.logging.slf4j.Log4jMarker does not implement org.slf4j.Marker.equals(Object)
org.slf4j.Marker.hashCode().
o LOG4J2-889: Header in layout should not be written on application startup if appending
to an existing file. Fixes LOG4J2-1030. Thanks to Maciej Karaś, Kenneth Leider.
o LOG4J2-918: Clarify documentation for combining async with sync loggers.
o LOG4J2-1078: GelfLayout throws exception if some log event fields are null. Thanks to Mikael
Ståldal.
改进
o LOG4J2-1017: Update Java platform from Java 6 to 7. From this version onwards, log4j 2
requires Java 7.
o LOG4J2-812: PatternLayout timestamp formatting performance improvement: replaced synchronized
SimpleDateFormat with Apache Commons FastDateFormat. This and better caching resulted in a ~3-30X faster
timestamp formatting.
o LOG4J2-1097: 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.
o LOG4J2-1096: Improved performance of ParameterizedMessage::getFormattedMessage by ~2X.
o LOG4J2-1120: LoggerConfig performance improvements: avoid unnecessary lock acquisition,
use more efficient data structure.
o LOG4J2-1125: PatternLayout performance improvement by caching and reusing a ThreadLocal
StringBuilder.
o LOG4J2-1114: Add thread name to status logger layout.
o LOG4J2-1010: Pass log event when interpolating logger properties.
o LOG4J2-1044: Support batchSize in FlumeAvroManager.
o LOG4J2-1065: Define org.apache.logging.log4j.Marker.equals(Object) and org.apache.logging.log4j.Marker.hashCode().
o LOG4J2-1063: Avoid creating temporary array object in org.apache.logging.slf4j.Log4jMarker.iterator().
o LOG4J2-890: log4j-web-2.1 should workaround a bug in JBOSS EAP 6.2. Thanks to Hassan Kalaldeh,
Robert Andersson, Remko Popma.
o LOG4J2-403: MongoDB appender, username and password should be optional. Thanks to Poorna
Subhash P, Jeremy Lautman.
o LOG4J2-1035: Log4j2 tries to SystemClassLoader when running on Google AppEngine.
o LOG4J2-1022: Allow a list of keys to be specified in the MDC pattern converter.
o LOG4J2-959: Fix FindBugs DM_DEFAULT_ENCODING bug in SimpleLogger.logMessage() and simplify
code.
o LOG4J2-1036: Update Apache Flume from 1.5.2 to 1.6.0.
o LOG4J2-1041: Update MongoDB driver from 2.11.2 to 2.13.2.
o LOG4J2-1018: Update database tests from H2 1.3.175 to 1.3.176.
o LOG4J2-1070: Update Java Mail from 1.5.2 to 1.5.4.
o LOG4J2-1079: Update Jackson from 2.5.3 to 2.5.4.
o LOG4J2-1879: Update Jackson from 2.5.4 to 2.6.0.
o LOG4J2-1092: Update Jackson from 2.6.0 to 2.6.1.
o LOG4J2-1104: Update Apache Commons Compress from 1.9 to 1.10.
移除
o Removed experimental interface LevelLogger which got committed to master by mistake.
更多内容请看发行说明。