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");
PropertyConfigurator.configure(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 :
org.brukkerlin.servlets.EddiLog4jServlet
org.brukkerlin.servlets.EddiLog4jServlet
properties
WEB-INFclasseslog4j.properties
1
And then you need a log4j.properties 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=org.apache.log4j.FileAppender
log4j.appender.simple.File=C:Program FilesApache GroupTomcat 4.1logseddi.log
#bepalen van de layout
log4j.appender.simple.layout=org.apache.log4j.SimpleLayout