log4j - Installation



log4j API package is distributed under the Apache Software License, a full-fledged open source license certified by the open source initiative.

The latest log4j version, including full-source code, class files and documentation can be found at https://logging.apache.org/log4j/2.x/download.html.

To install log4j on your system, download apache-log4j-2.25.1-bin.zip from the specified URL and follow the steps give below.

Step 1

Unzip the downloaded file in D:\Projects\apache-log4j-2.25.1-bin directory.

Step 2

This step is optional and depends on what features you are going to use from log4j framework. If you already have following packages installed on your machine then it is fine, otherwise you need to install them to make log4j work.

Set CLASSPATH Variable

Set the CLASSPATH environment variable to point to the log4j jar location. Assuming, you have stored log4j and related jars in Projects folder on various Operating Systems as follows.

OS Output
Windows Set the environment variable CLASSPATH to %CLASSPATH%;D:\Projects\apache-log4j-2.25.1-bin\log4j-core-2.25.1.jar;D:\Projects\apache-log4j-2.25.1-bin\log4j-api-2.25.1.jar;D:\Projects\apache-log4j-2.25.1-bin\log4j-layout-template-json-2.25.1.jar;
Linux export CLASSPATH=$CLASSPATH:Projects/apache-log4j-2.25.1-bin/log4j-core-2.25.1.jar:Projects/apache-log4j-2.25.1-bin/log4j-api-2.25.1.jar:Projects/apache-log4j-2.25.1-bin/log4j-layout-template-json-2.25.1.jar:.
Mac export CLASSPATH=$CLASSPATH:Projects/apache-log4j-2.25.1-bin/log4j-core-2.25.1.jar:Projects/apache-log4j-2.25.1-bin/log4j-api-2.25.1.jar:Projects/apache-log4j-2.25.1-bin/log4j-layout-template-json-2.25.1.jar:.
Advertisements