Log4j2 Asynchronous Logging

What to cover:

1. Log4j2 dependencies.

Step 1:

Create Java maven project in Eclipse, Intelli or any other Java IDE.

Step 2:

Check (skip archetype selection) and click Next.

Step 3:

Write group id just like package name format. Artifact Id is the name of project. Name and description are optional. Remaining fields remain same and then click Finnish.

Step 4:

Project structure look like this below.

Step 5:

Open pom.xml file and add below dependencies in between <dependencies> tag.

Step 6:

Sample pom.xml look like below.

Step 7:

Create java class with name as you want and package but not on default package on our java project.

Step 8:

Create Log4j2 xml file on any location you want in your drive. Sample below just copy and paste just change name of appender and logger you want.

Step 9:

Write below code on Java class.

Step 10:

Run the program and check log is created or not. If log file is created then open and see the message is print or not. Below is the sample message format print on log file.

--

--

Currently working as Full stack Java developer at Contour Software. Working on Java and IBM stack.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adil Abdullah

Currently working as Full stack Java developer at Contour Software. Working on Java and IBM stack.