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

import org.apache.logging.log4j.scala.Logging class MyClass extends BaseClass with Logging { def doStuff(): Unit = { logger.info("Doing stuff") } }

logger.debug("Logging in user {} with birthday {}", user.getName(), user.calcBirthday());

logger.debug(s"Logging in user ${user.getName} with birthday ${user.calcBirthday}")

Non-Blocking Queues in Async Appender

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

Log4j 2.7 includes a Logging trait that removes some boilerplate code. Your Scala code can now look like this:This also enables a more compact form of parameterized logging. Instead of the common Java form:In Scala, you can use string interpolation to achieve this: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: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

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!





In addition, the ThreadContext map is now garbage-free. This is disabled by default, users need to enable this explicitly.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.

Posted at 05:17PM Sep 26, 2016 by Remko Popma in General | |