logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alec Lebedev" <alec.lebe...@nextpage.com>
Subject How to configure log4j output file based on the servlet context?
Date Mon, 20 Aug 2007 21:39:58 GMT
I am using log4j in my webapp, which is packaged as webapp.war file. I
deploy this web application under multiple contexts in Tomcat by
renaming the WAR file and deploying it. For example, I create two copies
of the WAR file, e.g. context1.war and context2.war and deploy them.

 

Now, I want log4j to output logs from context1.war and context2.war to
different log files, e.g. context1.log and context2.log. I would like
this configuration to be done at deployment time automatically so that I
don't have to change it manually for each context.

 

One way to do this is to use a log4j Initialization Servlet as explained
here: http://logging.apache.org/log4j/docs/manual.html. If I use this
approach and inside of the log4j initialization servlet get servlet
context, then how do I change the target log4j output file at runtime?
Can I use PropertyConfigurator for that?

 

Are there any alternative approaches? For example, is there a way for
log4j to access servlet context properties, e.g.
log4j.appender.R.File=${catalina.home}/logs/${servlet.context}.log?

 

Thanks.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message