logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Bloch <bl...@laszlosystems.com>
Subject Re: best practice question: webapp relative filenames in FileAppenders
Date Fri, 12 Nov 2004 05:15:54 GMT
Thanks... I have a couple other requirements which constrain a solution 
the solution

The webapp (or even mulitple copies of the webapp deployed at different 
paths) has to work when dropped into a variety of containers.   Dorking 
with CLASSPATH and system properties are out.  I simply need someway to 
tell the FileAppenders that relative pathnames should be relative to 
some directory, I think.  But I need to do that *before* they try to 
read/access their files.

And you're right... I didn't actually describe what I do today.  I don't 
actually put my log4j.properties in the classpath.  My servlet code 
reads the prop file from somewhere else under WEB-INF and uses a 
PropertyConfigurator...  this all seems wrong though.

-Eric


Jacob Kjome wrote:

> Why not use a system property and reference it in your config using the 
> usual ${someproperty} syntax.  For instance...
> 
> ${catalina.home}/logs/mylog.log
> 
> If you want it to be dynamic per webapp, then you can set the system 
> property in a servlet context listener and then perform the manual 
> configuration of Log4j.
> 
> And if you are configuring manually via a startup servlet, why put 
> log4j.properties in the classpath?  It would get picked up there 
> automatically anyway (at least under a server using child-first 
> classloading behavior recommended by the servlet spec) assuming 
> log4j.jar is also in WEB-INF/lib.
> 
> Jake
> 
> At 05:02 PM 11/11/2004 -0800, you wrote:
>  >I want to use log4j to configure my webapp to write log files underneath
>  >it's WEB-INF directory.
>  >
>  >Today, I drop a log4j.properties file in WEB-INF/classes and I
>  >use code in the initialization of a servlet to programmatically fill in
>  >the .File property for a FileAppender (or a subclass of FileAppender)
>  >
>  >It would be nice if there was a way to specify the dir that the
>  >pathnames parsed in log4j.properties were relative to or some other
>  >technique for having the logfiles be relative to the webapp w/out
>  >writing code.
>  >
>  >Any advice?
>  >
>  >Thanks,
>  >-Eric
>  >
>  >
>  >---------------------------------------------------------------------
>  >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>  >For additional commands, e-mail: log4j-user-help@logging.apache.org
>  >
>  > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message