This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes log4j.properties not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "log4j.properties not found" Watch "log4j.properties not found" New topic
Author

log4j.properties not found

Rich Smyth
Ranch Hand

Joined: May 30, 2002
Posts: 87
I'm trying to get my Java app to use log4j. I've stored my log4j.properties
file in the same directory as my TestLogging.class file but Log4j does not find the properties file there. What did I do wrong?
When I run my program I get these messages:
log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@12f6684.
log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@12f6684 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@12f6684.
log4j: Trying to find [log4j.properties] using sun.misc.Launcher$AppClassLoader@12f6684 class loader.
log4j: Trying to find [log4j.properties] using ClassLoader.getSystemResource().
log4j: Could not find resource: [null].
log4j:WARN No appenders could be found for logger (logging.TestLogging).
log4j:WARN Please initialize the log4j system properly.
thanks for any clues,
Rich Smyth.
Chad Dalton
Greenhorn

Joined: Feb 19, 2003
Posts: 20
This is a servlet?
If so you need a class to configure log4j for the context

http://logging.apache.org/log4j/docs/manual.html
That above assumes you have a servlet level variable defined in your web.xml called log4j-init-file and it points to your .properties (or xml) file relative to the server's path. Initing via standalong is quite similar.
There are a ton of examples on that page above that should get you going. Pick the one that is closest to your implementation and let us know where you are having problems.
-c
[ March 29, 2004: Message edited by: Chad Dalton ]
Rich Smyth
Ranch Hand

Joined: May 30, 2002
Posts: 87
The tutorial I'm following has the instruction: "Save the following lines in a file named log4j.properties in the same directory as TestLogging.class "
I blindy did as instructed. My mistake. I should have noticed that this only works if TestLogging is in the default package. I stored the class in logging.TestLogging so the properties file was not at the root directory.
Thanks for the link Chad. I'm currently learning from http://www.vipan.com/htdocs/log4jhelp.html, which I find very well done.
Rich
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: log4j.properties not found
 
Similar Threads
remove log4j appender from an API
"tomcat" and "log4" with JSPWiki
moving from log4j 1.1.1 -> 1.2.8
log4j / eclipse / linux
Property file prob in Log4j