Configure Log4j in simple steps

Hi All,

The logging framework always plays a crucial part in your application. In this post i will explain how to configure Log4J in simple steps.

Put the Log4j jars file in classpath.

Step 2:
Create a log4j properties | xml file.

# Set root logger level to INFO

log4j.appender.STDOUT.layout.ConversionPattern=%d %p [%t] %C{1} - %m\n STDOUT STDOUT


<!--?xml version="1.0" encoding="UTF-8"?>

Step 3:
Write a program to load and start the logging in application

private static Logger logger = Logger.getLogger(TestJPAConfiguration.class);

public static void main(String[] args) {

//this is for basic loading

//Use property configurator to explicit load the log4j properties file.

//in case of using XML config, Use DOM Configurator
// DOMConfigurator.configure(“log4j.xml”);“Log4J Configured  successfully”);


Hope this helps. 🙂

R Vashi

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.