The Apache Log4J logging utility is a must have for most Java programmers that need robust logging for Java application logging. Let’s go through a step by step tutorial from start to finish. There are a list of assumptions below that will be the basis for all of my tutorial steps.
- I am working in a windows environment.
- I am developing all Java applications with Eclipse IDE.
- I have 7-ZIP installed to unzip the archive.
Step 1 – Download log4j
- Go to Download Apache Log4j page.
- Click on the link apache-log4j-2.10.0-bin.zip for Apache Log4j 2 binary (zip).
- Click on the link from the suggested mirror site.
Step 2 – Save Zip File
- Save the zip file to your Downloads folder (Figure 1).
- Go to the Download folder and right click on the apache-log4j-2.10.0-bin archive.
- Select 7-ZIP and then Open Archive.
Step 3 – Copy and Extract
- Select log4j-api-2.10.0.jar and log4j-core-2.10.0.jar jar files (Figure 2).
- Click Extract.
- Copy these two jars to your lib or classpath directory (Figure 3).
Step 4 – Configure Eclipse
- Right Click on your Java Project >> Build Path >> Configure Build Path.
- Click on Add External Jars (Figure 4).
- Select log4j-api-2.10.0.jar and log4j-core-2.10.0.jar.
- Apply and Close.
- See Figure 5 for a screenshot of the log4j working library (Figure 6).