Log4j is a logging mechanism that is in Apache foundation project. Log4j is for Java project. Here, to add logging feature to your Java project, you can use one as following ways:
Manually
- Visit http://logging.apache.org/log4j/
- Download the Log4j jar library
- Manually include it into your project dependency
- All manage by yourself, you need to do everything
If there is Log4j version upgrade, you need to repeat above steps again.
Maven 2 – Recommended
Use Maven 2 or 3 to handle the build for you. See how to install it in previous post.
You can just add into your pom.xml as following:
<dependencies> <!-- other dependencies --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.15</version> </dependency> <!-- other dependencies --> </dependencies>
So with maven, when you want to change version, you just need to update the version tag as above (Ex: 1.2.15)
One reply on “Add log4j to your Java project”
Answer is in the post description.