DEV Community

Cover image for In One Minute : log4j2
Rakesh KR
Rakesh KR

Posted on

2

In One Minute : log4j2

Apache Log4j 2 is the successor of Log4j 1 which was released as GA version in July 2014.

The framework was rewritten from scratch and has been inspired by existing logging solutions, including Log4j 1 and java.util.logging.

One of the most recognized features of Log4j 2 is the performance of the "Asynchronous Loggers".

The library reduces the need for kernel locking and increases the logging performance by a factor of 12.
For example, in the same environment Log4j 2 can write more than 18,000,000 messages per second, whereas other frameworks like Logback and Log4j 1 just write < 2,000,000 messages per second.

Log4j 2 allows users to define their own log levels.

Log4j can be configured through a configuration file or through Java code.

Configuration files can be written in XML, JSON, YAML, or properties file format.
Within a configuration, you can define three main components: Loggers, Appenders, and Layouts.

Configuring logging via a file has the advantage that logging can be turned on or off without modifying the application that uses Log4j.

Official Website :- https://logging.apache.org/log4j/2.x/

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay