Quoting Jitendra Kharche <[EMAIL PROTECTED]>:

> Hi Paul,
>
> Thanks for the help.
> This is the best way fot standalone java applications. Whereas I am
> having a web application and I don't want to change the startup script
> of webserver.
>
> Is there any other way?
>

Sure.  If you are using a webapp, just create a ServletContextListener and as
the first thing in the contextInitialized() method, set the system property. 
Then perform manual Log4j configuration.  Note that you might want to put a
dummy log4j.xml file in WEB-INF/classes to avoid autoconfiguration finding a
Log4j config file elsewhere in the classpath (assuming that you don't put your
log4j.xml file for manual configuration in the classpath, which probably makes
sense since the system property refrences wouldn't be resolved before
autoconfiguration).

Jake

> Regards,
> Jitendra
>
> -----Original Message-----
> From: Paul Smith [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 19, 2005 12:49 PM
> To: Log4J Users List
> Subject: Re: How to specify log file path using env variable
>
> if you start your application and set the property via the standard java
> system property, it works fine.
>
> eg.
>
> java -classpath <blah> -DMY_APP=c:\myapp  ....
>
> Then you can embed the MY_APP in your log4j configuration file.
>
> cheers,
>
> Paul
>
> Jitendra Kharche wrote:
>
> >Hi All,
> >
> >I am using log4j for looging my applocation log on windows. The log
> >file path I have specified in the log4j.xml file is currently a windows
>
> >path e.g. C:\myapp\logs\myapp.log.
> >I want to remove the hardcoded path (C:\myapp) and replace it with a
> >system environment variable MY_APP (=C:\myapp). How can I do that?
> >Furthermore, this will help me in migration my application from windows
>
> >to unix or other OSs.
> >
> >Please help.
> >
> >Regards,
> >Jitendra Kharche
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to