Apache Logging Services
Monday September 26, 2016
A sneak peak into Log4j 2.7
Log4j 2.7 will be released in a few days. The community is now reviewing the release for any last minute showstopper. Meanwhile, you may be interested in a sneak peek into what is coming.
Log4j 2 is nominated for the JAX Innovation Awards! Do you like its performance, garbage-free logging, and easy and flexible configuration? Log4j 2 needs your love. Vote for Log4j 2! Voting closes September 29th, 2016. |
Scala API
Log4j 2.7 includes a Logging trait that removes some boilerplate code. Your Scala code can now look like this:import org.apache.logging.log4j.scala.Logging class MyClass extends BaseClass with Logging { def doStuff(): Unit = { logger.info("Doing stuff") } }This also enables a more compact form of parameterized logging. Instead of the common Java form:
logger.debug("Logging in user {} with birthday {}", user.getName(), user.calcBirthday());In Scala, you can use string interpolation to achieve this:
logger.debug(s"Logging in user ${user.getName} with birthday ${user.calcBirthday}")
Non-Blocking Queues in Async Appender
In addition to Log4j 2's Asynchronous Loggers, which are based on the LMAX Disruptor library, the 2.7 release allows you to configure the Async Appender to use a different queue implementation, including a few non-blocking ones:- ArrayBlockingQueue - This is the default implementation that uses ArrayBlockingQueue
- LinkedTransferQueue - This uses the JDK LinkedTransferQueue which was introduced in Java 7.
- JCToolsBlockingQueue - This uses the MPSC bounded lock-free queue in JCTools.
- DisruptorBlockingQueue - This uses the Conversant Disruptor BlockingQueue. (Not to be confused with the LMAX Disruptor.)
Custom Context Data Injection
Context data is data that is set by the application to be included in all subsequent log events. The default source for context data is the ThreadContext.From Log4j 2.7, users can configure a custom ContextDataInjector that can
- take context data from any source, and
- use values of any type (not just Strings).
...and much more
RoutingAppender can now be configured with scripts, a new ScriptAppenderSelector was introduced that creates an Appender specified by a Script, FileAppender (and its Rolling equivalent) can now create files on-demand, and there are various other improvements.Vote For Us!

Log4j 2 is nominated for the JAX Innovation Awards! Do you like its performance, garbage-free logging, and easy and flexible configuration? Log4j 2 needs your love. Vote for Log4j 2! |
Posted at 05:17PM Sep 26, 2016
by Remko Popma in General |
Comments [7]
|
Posted by Niccolo on September 30, 2016 at 08:27 PM UTC #
Posted by Akki12 on February 02, 2019 at 05:13 AM UTC #
Posted by Carly Donovan on July 18, 2019 at 07:02 AM UTC #
Posted by sintroïde on July 20, 2019 at 05:13 PM UTC #
Posted by HoneyBeeNutrition.com on July 27, 2019 at 03:59 PM UTC #
Posted by Danny on September 11, 2019 at 01:20 PM UTC #
Posted by Casimob on September 12, 2019 at 06:26 AM UTC #