*
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
Author

using log4j in Tomcat

YanJun Tong
Greenhorn

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 simplelog.properties.I put this file under the folder c:\tomcat\webapps\catania-web\WEB-INF. I put all my settings in the web.xml as follows:
<context-param>
<param-name>LogConfig</param-name>
<param-value>cataniaLog.properties</param-value>
</context-param>
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/cataniaLog.properties</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 simplelog.properties thanks in advance
Eelco den Heijer
Ranch Hand

Joined: Jan 17, 2002
Posts: 61
you can put the log4j.properties 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 log4j.properties 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
 
GeeCON Prague 2014
 
subject: using log4j in Tomcat