Log4j Maven configuration example

Logging is essential part of programming. It helps developer to track code workflow and fix bugs efficiently. If we get any issue in the code, we check logs for that workflow or functionality.

Log4j is fast , reliable logging framework and can be easily integrated with the code. It is possible to enable logging at run time without using

Lets integrate Log4j in simple maven project.

Steps:

1) Create simple maven java project.

2) Put log4j entry in pom.xml .

3) Update maven project to download require jar

Right click on project-> Maven -> update project

4) Sample class for Logger

Create a class called “LoggingMain.java” in src/main/java in package org.arpit.java2blog

5) Run program:

When you run above program , you will get below output:

Bingo!! we have successfully configured log4j in maven project.

Add Comment