This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
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.
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 ]
Joined: May 30, 2002
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