<Appenders>
<Socket name="socket" host="localhost" port="9500"/>
</Appenders>
2.11.2 (2019-02-04)
This release contains bugfixes and minor enhancements.
Due to a break in compatibility in the SLF4J binding, Log4j now ships with two versions of the SLF4J to Log4j adapters.
log4j-slf4j-impl
should be used with SLF4J 1.7.x and earlier and log4j-slf4j18-impl
should be used with SLF4J 1.8.x and later.
As of Log4j 2.9.0, the Log4j API was modified to use java.util.ServiceLoader
to locate Log4j implementations, although the former binding mechanism is still supported.
The Log4j API JAR is now a multi-release JAR to provide implementations of Java 9 specific classes.
Multi-release JARs are not supported by the OSGi specification so OSGi modules will not be able to take advantage of these implementations but will not lose functionality as they will fall back to the implementations used in Java 7 and 8.
Applications using Spring Boot must add the Multi-Release header to the JAR manifest or the Java 9+ classes will be ignored.
More details on the new features and fixes are itemized below.
Note that some tools are not compatible with multi-release JARs and may fail trying to process class files in the META-INF/versions/9
folder.
Those errors should be reported to the tool vendor.
Note that subsequent to the 2.9.0 release, for security reasons, Log4j does not process DTD in XML files. If you used DTD for including snippets, you have to use XInclude or Composite Configuration instead.
Also subsequent to the 2.9.0 release, for security reasons, SerializedLayout
is deprecated and no longer used as default in the Socket and JMS appenders.
SerializedLayout
can still be used as before, but has to be specified explicitly.
To retain old behaviour, you have to change configuration like:
into:
<Appenders>
<Socket name="socket" host="localhost" port="9500">
<SerializedLayout/>
</Socket>
</Appenders>
We do, however, discourage the use of SerializedLayout
and recommend JsonLayout
as a replacement:
<Appenders>
<Socket name="socket" host="localhost" port="9500">
<JsonLayout properties="true"/>
</Socket>
</Appenders>
Note that the XML, JSON and YAML formats changed in the 2.11.0 release: they no longer have the timeMillis
attribute and instead have an Instant
element with epochSecond
and nanoOfSecond
attributes.
The Log4j 2.11.2 API, as well as many core components, maintains binary compatibility with previous releases.
Log4j 2.11.2 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
-
PatternLayout %date conversion pattern should render time zone designator for ISO-ISO8601. (for LOG4J2-1246 by Gary Gregory)
-
JDBC Appender should reconnect to the database when a connection goes stale. (for LOG4J2-2496 by Gary Gregory)
-
Let JDBC PoolingDriverConnectionSource with Apache Commons DBCP configure a PoolableConnectionFactory. (for LOG4J2-2505 by Gary Gregory)
-
Allow a JDBC Appender to truncate strings to match a table’s metadata column length limit. (for LOG4J2-2509 by Gary Gregory)
Changed
-
Switch from CLIRR to RevAPI for detecting API changes. (for LOG4J2-1576 by Ralph Goers)
-
Improve exception logging performance. ThrowableProxy construction uses a faster method to discover the current stack trace. ThrowablePatternConverter and ExtendedThrowablePatternConverter default configurations no longer allocate an additional buffer for stack trace contents. (for LOG4J2-2391 by Carter Kozak)
-
Better handling of %highlight pattern when using jul-bridge. (for LOG4J2-2405 by Gary Gregory, Marco Herrn)
-
Let the NullAppender default its name to "null". (for LOG4J2-2447 by Gary Gregory)
-
Update Jackson from 2.9.6 to 2.9.7. (for LOG4J2-2468 by Gary Gregory)
-
Update Apache Commons Compress from 1.17 to 1.18. (for LOG4J2-2469 by Gary Gregory)
-
Update Apache Commons CSV from 1.5 to 1.6. (for LOG4J2-2470 by Gary Gregory)
-
Update javax.mail from 1.6.1 to 1.6.2. (for LOG4J2-2471 by Gary Gregory)
-
Update mongo-java-driver 3 from 3.8.0 to 3.8.2. (for LOG4J2-2472 by Gary Gregory)
-
JDBC Appender should release parameter resources ASAP. (for LOG4J2-2489 by Gary Gregory)
-
Allow all Appenders to optionally carry a Property array. (for LOG4J2-2491 by Gary Gregory)
-
Update MongoDB driver from 3.8.2 to 3.9.0 for log4j-mongodb3 module. (for LOG4J2-2503 by Gary Gregory)
Fixed
-
Logging with a lambda expression with a method call that also logs would cause logs within method call to reference line num and method name of the parent method. (for LOG4J2-1570 by Ralph Goers)
-
Fixed Appenders section in Extending Log4j. (for LOG4J2-1571 by Ralph Goers, torbenmoeller)
-
Direct write was creating files with the wrong date/time. (for LOG4J2-1906 by Ralph Goers)
-
Expose LoggerContext.setConfiguration as a public method. (for LOG4J2-2009 by Ralph Goers)
-
Use the file pattern as the FileManager "name" when no filename is present. (for LOG4J2-2061 by Ralph Goers)
-
StackOverflowError at AwaitCompletionReliabilityStrategy. (for LOG4J2-2134 by Gary Gregory, David del Amo Mateos)
-
Fix memory leak in ReusableParameterizedMessage. (for LOG4J2-2201 by Carter Kozak)
-
Load PropertySources from any accessible ClassLoader. Hide any exceptions that may occur accessing a PropertySource. (for LOG4J2-2266 by Ralph Goers)
-
ReusableObjectMessage parameter is properly passed to appenders (#203). (for LOG4J2-2363 by Carter Kozak, Brian Laub)
-
NameAbbreviator correctly abbreviates first fragments (#188). (for LOG4J2-2365 by Carter Kozak, Eugene Zimichev)
-
Pre-deployment of PersistenceUnit that using Log4j as session logger failed (#198). (for LOG4J2-2397 by Gary Gregory, EckelDong)
-
Exceptions are added to all columns when a JDBC Appender’s ColumnMapping uses a Pattern. (for LOG4J2-2413 by Gary Gregory, Andres Luuk)
-
NullPointerException when closing never used RollingRandomAccessFileAppender. (for LOG4J2-2418 by Gary Gregory, Jonas Rutishauser)
-
Handle some unchecked exceptions while loading plugins. (for LOG4J2-2422 by Gary Gregory,
rswart
) -
Setting a null ErrorHandler on AbstractAppender is not allowed and will no-op as expected. (for LOG4J2-2441 by Carter Kozak)
-
ErrorHandler is invoked with a LogEvent and Throwable when possible, where previously only a string was used. (for LOG4J2-2444 by Carter Kozak)
-
Add Log4j-slf4j18-impl dependency to BOM POM. (for LOG4J2-2453 by Ralph Goers, theit)
-
RollingRandomAccessFileManager ignores new file patterns from programmatic reconfiguration. (for LOG4J2-2457 by Gary Gregory, Heiko Schwanke)
-
ColumnMapping literal not working. (for LOG4J2-2466 by Gary Gregory, Paolo Bonanomi)
-
org.apache.log4j.SimpleLayout and ConsoleAppender missing in log4j-1.2-api. (for LOG4J2-2476 by Gary Gregory, Al Bundy)
-
AbstractStringLayoutStringEncodingBenchmark returns the computed variables on each benchmark to avoid DCE. (for LOG4J2-2478 by Carter Kozak, Diego Elias Costa)
-
Avoid NullPointerExceptions in org.apache.logging.log4j.core.config.AbstractConfiguration for null arguments. (for LOG4J2-2481 by Gary Gregory)
-
BasicContextSelector cannot be used in a OSGI application. (for LOG4J2-2482 by Gary Gregory, Rob Gansevles)
-
SizeBasedTriggeringPolicy was not honored when using the DirectWriteRolloverStrategy if the machine restarts. (for LOG4J2-2485 by Ralph Goers, Giovanni Matteo Fumarola)
-
JmsAppender reconnectIntervalMillis cannot be set from a configuration file. (for LOG4J2-2497 by Gary Gregory)
-
JMS Appender may throw a NullPointerException when JMS is not up while the Appender is starting. (for LOG4J2-2499 by Gary Gregory)
-
Document that Properties element must be the first configuration element. (for LOG4J2-2500 by Ralph Goers)
-
JDBC Appender fails when using both parameter, source, and literal ColumnMapping elements. (for LOG4J2-2508 by Gary Gregory)
-
Make Strings.toRootUpperCase a static method so it can be accessed. (for LOG4J2-2514 by Ralph Goers, smilebrian0515)
-
Configuration documentation referenced incorrect method name. (for LOG4J2-2515 by Ralph Goers, MakarovS)
-
Fix regression using MapMessageLookup.lookup with MapMessages that do not implement StringMapMessage. (for LOG4J2-2522 by Carter Kozak, Adam Lesiak)
-
Prevent ConcurrentModificationException while iterating over ListAppender events. (for LOG4J2-2527 by Carter Kozak)
-
Generalize checks using MapMessage implementations with do not extend StringMapMessage. Introduce new JAVA_UNQUOTED MapMessage format type based on the JAVA formatting, but without quoted values. (for LOG4J2-2530 by Carter Kozak, Travis Spencer)
-
Fix a regression introduced by LOG4J2-2301 in 2.11.1 allowing allocation to occur in AsyncLoggerConfig. (for LOG4J2-2533 by Carter Kozak, Michail Prusakov)
-
CronTriggeringPolicy was not rolling properly, especially when used with the SizeBasedTriggeringPolicy. (for LOG4J2-2542 by Ralph Goers)
-
Add Log4j-to-SLF4J to BOM pom.xml. (for LOG4J2-2543 by Ralph Goers, Dermot Hardy)