File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes using log4j in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "using log4j in Tomcat" Watch "using log4j in Tomcat" New topic

using log4j in Tomcat

YanJun Tong

Joined: Jun 11, 2003
Posts: 27
I use log4j to trace any debig information in my application.However since it is my first time to use log4j I got some problem. Suppose my appication is in the path c:\tomcat\webapps\catania-web Since we all know I need a file to config my log4j.Let us say the file is called put this file under the folder c:\tomcat\webapps\catania-web\WEB-INF. I put all my settings in the web.xml as follows:
So I can trigger this parameter by getServletContext().
The problem is that I do not know how to set the <param-value> tag so that my application can find my properties file. My current approach is to use the absolute path i.e. <param-value>c:/tomcat/webapps/catania-web/WEB-INF/</param-value>. But I know it is not a good idea to put absolute path here. Could anybody tell me how to write a abstract path and where should I put my thanks in advance
Eelco den Heijer
Ranch Hand

Joined: Jan 17, 2002
Posts: 61
you can put the for server level (used by the container) in $CATALINA_HOME/common/classes (or anywhere on the classpath of tomcat); this will regulate all debug messages coming from the classloader of tomcat itself.

For each web application you can put the in the WEB-INF/classes directory. You can explicitly instantiate properties file like you say, but it is not necessary.

== <br />Rgrds,<br />Eelco<br /> <br />SCJP, SCJD, SCBCD, SCWD, SCEA
I agree. Here's the link:
subject: using log4j in Tomcat
It's not a secret anymore!