Javatpoint Logo
Javatpoint Logo

Log4j Maven

First of all, we need to understand what Maven is. A Maven is a tool for building java based project that offers several benefits and options by making build processes powerful, understandable and easy. Maven takes care of downloading all necessary dependencies and including them correctly in the project. Maven is the part of the Apache Software Foundation.

Following are the most basic steps to configure log4j logging support in our project:

1) Create a Maven Project:

  • Go to File menu then choose New -> Project
Log4j Example
  • Select Maven-> Maven Project.
Log4j Example
  • Mention the Group Id and Artifact ID and click on the Finish button.
Log4j Example

2) Update the pom.xml file:

Add the following given dependencies to pom.xml file, or you can go to the following URL: https://mvnrepository.com/artifact/log4j/log4j/1.2.17

  • Now, press ctrl+s on pom.xml file or right-click on your project and go to Maven-> Update Project to download the required jar.

3) Sample Class for Logger:

  • Create a simple HelloWorld program with basic configuration.

4) Run the Program:

  • When you compile and then run the above program, you will get the following output:

Next TopicLog4j Properties




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA