This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I am trying to make changes to an application which uses a natively developed logging class. We have integrated log4j with custom class, so that it behined the scene log4j is used for logging
Right now the log4j.properties is read using
We have placed the log4j.properties in root of src direcotry, i.e the code structure is as follows
src
|
|--->com
| |
| |-->testcompany
| | |
| | |-->util
| | | |
| | | | -->someutil.java
| |
|->log4j.properties
What we want to do is instead of reading from root of src we want to read from config/LogConfig directory like show below
Web applications don't have a "src" directory. Their classes are stored either in WEB-INF/classes or in a jar in WEB-INF/lib. So you should base your design planning on that rule. Once you have figured out where you want the config file to go (I put mine in WEB-INF/classes) then you can figure out how to get your deployment procedure (where you build your WAR or EAR for the application) to put it there.
(Also you might want to spell "congfig" better than that... )
I cannot speak for other containers (although I would think it would be similar), but for Tomcat, all that is required is that "log4j.properties" exist directly under WEB-INF/classes or WEB-INF/lib in my web application, along with the log4j jar file in WEB-INF/lib.
If log4j-xxx.jar is located on the web application's classpath (ie WEB-INF/lib), Tomcat should attempt to implement log4j. If I am missing my log4j.properties, it sends a message to standard out (catalina.out) that log4j was not properly initialized.
Also, I haven't had to call "PropertyConfigurator.configure("log4j.properties");", it's generally been enough simply to call
OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
John Lincoln
Ranch Hand
Joined: Feb 11, 2003
Posts: 192
posted
0
Hi Paul & Pete,
Thanks for the response.
Paul,
I have currently in WEB-INF/classes/log4j.properties -- works
When i place the file in WEB-INF/classes/com/somecompany/config/log4j.properties -- does not work
Please let me know how can i read from com/somecompany/config directory