Javatpoint Logo
Javatpoint Logo

Installation of Log4j

API package of Log4j is distributed under the Apache Software License. The latest version of log4j including full source code, class files, and documentation can be found at http://logging.apache.org/log4j/1.2/

For windows download the .zip file or for Linux OS use the .tar.gz file. Here, I am using Windows OS.

Installation of Log4j
  • Unzip the zip file to your local directory.
  • Open the Log4j folder from the saved location.
Installation of Log4j
  • Now, you need to set up the PATH and CLASSPATH. For this, go to My Computer and right-click on it and select the properties from the popup menu. Then add the path of log4J directory.
Installation of Log4j

For Linux:

  • Add the log4j jar file in your java project. To do this, create a java project in eclipse and right-click on your java project name and select "Build Path -> Configure Build Path".
Installation of Log4j

Go to the Libraries tab and click on Add External Jars button.

Installation of Log4j

Browse the jar file of log4j (i.e., log4j-1.2.17.jar) from your unzipped folder.

Installation of Log4j

Click on OK button to close the dialogue.

Installation of Log4j

Supporting Libraries

We can use log4J to log information to various destinations, such as sending an email, to a file or to a database. There are lists of libraries that we need to put to the classpath so that log4j can pick it up and use it. If we need to send the email from log4j, we should have the email library jar file.

All the libraries are optional and depend on us that what features, we are going to use with log4j framework:

  • JavaMail API (mail.jar): The e-mail based logging feature in log4j requires the Java Mail API (mail.jar) to be installed on your machine.
  • JavaBeans Activation Framework: The Java Mail API will also require that the JavaBeans Activation Framework (activation.jar) be installed on your machine.
  • Java Message Service: The JMS-compatible features of log4j will require that both JMS and Java Naming and Directory Interface JNDI be installed on your machine.
  • XML Parser: You require a JAXP-compatible XML parser to use log4j. Make sure you have Xerces.jar installed on your machine.

Next TopicLog4j Architecture




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA