How to store the log file with web application path?
1 posts in topic
Flat View  Flat View

Posted By:   walker_skyinn
Posted On:   Monday, February 24, 2003 06:33 AM

In local, I can use :
to store the log file under my web application path,
but I didn't know how to store it in server with a NOT absolute path,
By tomcat, if I use:
the log file will store in $TOMCAT_PATH$/bin folder,
but I want it store in d:/myweb folder.
so It's problem with my web application!

Is there some method such as:
or others?

thank you very much:)

Re: How to store the log file with web application path?

Posted By:   Gert_Cuppens  
Posted On:   Saturday, April 19, 2003 06:06 AM

It's almost 2 months since you wrote this, so I suppose I'm too late.
Nevertheless, I'll send you a piece of code I found in "professional Apache Tomcat", from Wrox.

You need an initialisation servlet in which you write :
String path = getServletContext().getRealPath("/");
String properties = path + getInitParameter("properties");

Via getServletContext you get the full path of the servlet. You add to this the name of the properties-file which you have defined in your web.xml like this :




And then you need a file, in which you write :

# definitie van simple logger
# level van de logger is DEBUG (dus op één na hoogste; hoogste = ALL)
log4j.logger.eddi.simple=DEBUG, simple

#definitie van de appender : bepaalt naar waar de logging geschreven wordt
log4j.appender.simple.File=C:Program FilesApache GroupTomcat 4.1logseddi.log

#bepalen van de layout
About | Sitemap | Contact