Forums Register Login

log4j.properties not found

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
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
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 5597 times.
Similar Threads
log4j / eclipse / linux
"tomcat" and "log4" with JSPWiki
remove log4j appender from an API
Property file prob in Log4j
moving from log4j 1.1.1 -> 1.2.8
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 08:58:25.