aspose file tools*
The moose likes Tomcat and the fly likes Path to locate properties file of log4j Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Path to locate properties file of log4j" Watch "Path to locate properties file of log4j" New topic
Author

Path to locate properties file of log4j

Haroldo Nascimento
Ranch Hand

Joined: Aug 14, 2003
Posts: 79
I am using log4j in my WebApplication.
Where I must configurate path or classpath in Tomcat to locate logXX.properties (properties file of log4j).
Thanks
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

you don't need to configure log4j or tomcat in any special way.

Log4j will attempt to find a log4j.properties file on the classpath. So if you place your log4j.properties file in WEB-INF/classes it's pretty much guaranteed to be found. (That's what I do for my apps, and it works).
Haroldo Nascimento
Ranch Hand

Joined: Aug 14, 2003
Posts: 79
It does not works in mey tomcat. How I can configurate my classpath in tomcat? I need alter any .bat (what) or only web.xml or struts-config.xml is necessary ?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Classpath is something you should *not* concern yourself with for Tomcat. Tomcat takes care of its own classpath settings. Read up on Tomcat's classloaders here:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html

What do you have in the following directories:

CATALINA_HOME/common/lib
your_webapp/WEB-INF/lib
your_webapp/WEB-INF/classes

Also, check tomcat's logs for error messages. If there's a mistake in log4j.properties, it might appear that log4j is not configured at all. In this case, log4j reverts to using System.out.

on windows: CATALINA_HOME\logs\stderr.log or CATALINA_HOME\logs\stdout.log
on unix: CATALINA_HOME/logs/catalina.out

Also, how are you using log4j in your application? Are you using a configurator or just the 'easy' way like:



Finally, please tell us what you mean by "it does not work".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Path to locate properties file of log4j
 
Similar Threads
log4j error message - please send solutions
How not to hard-code file location in java?
Unable to set classpath for log4j
system variables in .properties file
can I set the path in my code to refer a properties file?