IOW you shouldn't need to use a Configurator. In any case, you should be using DOMConfigurator with log4j.xml if for some reason you need to do explicit config
Main Topics
Browse All TopicsHi,
I am configuring Log4j for logging in my java application
I get an warning
log4j:WARN Please initialize the log4j system properly.
and my logs are not generated. My log4j exists at the URL passed
I have created URL with my method
public URL doConfiguration()
{
URL url = getClass().getResource("lo
System.out.println("URL is "+url);
return url;
}
Now when I run my program I get message
URL is file:/C:/Documents%20and%2
log4j:WARN Please initialize the log4j system properly.
Please help me in fixing my log4j conf
Please find my main class code snippet and log4j.xml in Code option below
Kind Regards
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Many Thanks it works when I have kept my log4j.xml at the root folder
How can I rename log4j.xml file
May be I can do this using DOMConfigurator
When I am using
File f = new File("C:\\SMEC\\Conf\\log4
System.out.println("Conf File Exists: "+f.exists());
URL url = getClass().getResource("C:
System.out.println("URL is "+url);
URL url = mn.doConfiguration();
DOMConfigurator.configure(
I get ERROR
File Exists: true
Conf File Exists: true
URL is null
Exception in thread "main" java.lang.NullPointerExcep
at org.apache.log4j.xml.DOMCo
at org.apache.log4j.xml.DOMCo
at org.apache.log4j.xml.DOMCo
at org.apache.log4j.xml.DOMCo
at outlook.Main.main(Main.jav
Java Result: 1
Why I am getting URL null.
I wanted to rename the log4j.xml file
As I may have to change the location of log4j.xml in near future and I have multiple java applications running on same server.
May be I am thinking when I set the classpath for all applications then my application should not confuse which log4j.xml file to use
Thanks and regards
Business Accounts
Answer for Membership
by: CEHJPosted on 2009-05-10 at 05:03:59ID: 24347910
Put log4j.xml at the root of the app and it should be loaded automatically