<Appenders>
<Socket name="socket" host="localhost" port="9500"/>
</Appenders>
2.11.2
- Release date
-
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.
Added
-
PatternLayout %date conversion pattern should render time zone designator for ISO-ISO8601. (LOG4J2-1246)
-
JDBC Appender should reconnect to the database when a connection goes stale. (LOG4J2-2496)
-
Let JDBC PoolingDriverConnectionSource with Apache Commons DBCP configure a PoolableConnectionFactory. (LOG4J2-2505)
-
Allow a JDBC Appender to truncate strings to match a table’s metadata column length limit. (LOG4J2-2509)
Changed
-
Switch from CLIRR to RevAPI for detecting API changes. (LOG4J2-1576)
-
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. (LOG4J2-2391)
-
Better handling of %highlight pattern when using jul-bridge. (LOG4J2-2405)
-
Let the NullAppender default its name to "null". (LOG4J2-2447)
-
Update Jackson from 2.9.6 to 2.9.7. (LOG4J2-2468)
-
Update Apache Commons Compress from 1.17 to 1.18. (LOG4J2-2469)
-
Update Apache Commons CSV from 1.5 to 1.6. (LOG4J2-2470)
-
Update javax.mail from 1.6.1 to 1.6.2. (LOG4J2-2471)
-
Update mongo-java-driver 3 from 3.8.0 to 3.8.2. (LOG4J2-2472)
-
JDBC Appender should release parameter resources ASAP. (LOG4J2-2489)
-
Allow all Appenders to optionally carry a Property array. (LOG4J2-2491)
-
Update MongoDB driver from 3.8.2 to 3.9.0 for log4j-mongodb3 module. (LOG4J2-2503)
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. (LOG4J2-1570)
-
Fixed Appenders section in Extending Log4j. (LOG4J2-1571)
-
Direct write was creating files with the wrong date/time. (LOG4J2-1906)
-
Expose LoggerContext.setConfiguration as a public method. (LOG4J2-2009)
-
Use the file pattern as the FileManager "name" when no filename is present. (LOG4J2-2061)
-
StackOverflowError at AwaitCompletionReliabilityStrategy. (LOG4J2-2134)
-
Fix memory leak in ReusableParameterizedMessage. (LOG4J2-2201)
-
Load PropertySources from any accessible ClassLoader. Hide any exceptions that may occur accessing a PropertySource. (LOG4J2-2266)
-
ReusableObjectMessage parameter is properly passed to appenders (#203). (LOG4J2-2363)
-
NameAbbreviator correctly abbreviates first fragments (#188). (LOG4J2-2365)
-
Pre-deployment of PersistenceUnit that using Log4j as session logger failed (#198). (LOG4J2-2397)
-
Exceptions are added to all columns when a JDBC Appender’s ColumnMapping uses a Pattern. (LOG4J2-2413)
-
NullPointerException when closing never used RollingRandomAccessFileAppender. (LOG4J2-2418)
-
Handle some unchecked exceptions while loading plugins. (LOG4J2-2422)
-
Setting a null ErrorHandler on AbstractAppender is not allowed and will no-op as expected. (LOG4J2-2441)
-
ErrorHandler is invoked with a LogEvent and Throwable when possible, where previously only a string was used. (LOG4J2-2444)
-
Add Log4j-slf4j18-impl dependency to BOM POM. (LOG4J2-2453)
-
RollingRandomAccessFileManager ignores new file patterns from programmatic reconfiguration. (LOG4J2-2457)
-
ColumnMapping literal not working. (LOG4J2-2466)
-
org.apache.log4j.SimpleLayout and ConsoleAppender missing in log4j-1.2-api. (LOG4J2-2476)
-
AbstractStringLayoutStringEncodingBenchmark returns the computed variables on each benchmark to avoid DCE. (LOG4J2-2478)
-
Avoid NullPointerExceptions in org.apache.logging.log4j.core.config.AbstractConfiguration for null arguments. (LOG4J2-2481)
-
BasicContextSelector cannot be used in a OSGI application. (LOG4J2-2482)
-
SizeBasedTriggeringPolicy was not honored when using the DirectWriteRolloverStrategy if the machine restarts. (LOG4J2-2485)
-
JmsAppender reconnectIntervalMillis cannot be set from a configuration file. (LOG4J2-2497)
-
JMS Appender may throw a NullPointerException when JMS is not up while the Appender is starting. (LOG4J2-2499)
-
Document that Properties element must be the first configuration element. (LOG4J2-2500)
-
JDBC Appender fails when using both parameter, source, and literal ColumnMapping elements. (LOG4J2-2508)
-
Make Strings.toRootUpperCase a static method so it can be accessed. (LOG4J2-2514)
-
Configuration documentation referenced incorrect method name. (LOG4J2-2515)
-
Fix regression using MapMessageLookup.lookup with MapMessages that do not implement StringMapMessage. (LOG4J2-2522)
-
Prevent ConcurrentModificationException while iterating over ListAppender events. (LOG4J2-2527)
-
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. (LOG4J2-2530)
-
Fix a regression introduced by LOG4J2-2301 in 2.11.1 allowing allocation to occur in AsyncLoggerConfig. (LOG4J2-2533)
-
CronTriggeringPolicy was not rolling properly, especially when used with the SizeBasedTriggeringPolicy. (LOG4J2-2542)
-
Add Log4j-to-SLF4J to BOM pom.xml. (LOG4J2-2543)