Hi Jake, Thanks. The way you have suggested is another good way. But my problem is little different. I want to use a system variable in the path of log file. If I do using your method, it will still be a hardcoded path because once I code it in the ServletContextListener, I can not change it on the fly during the installation of my product. I don't want to keep my log files in the webserver deployment directory. The log files are kept somewhere else e.g. C:\myapp\logs. For this, as I have explained in my first mail, I set a system variable MY_APP=C:\myapp and this path depends on the installation directory which e.g. on unix can be \home\usr\myapp. I can extend your suggestion to set this path in a configuration file or in servelt init parameters, read from there and set it. But this makes redundant information for the variable MY_APP. It is defined in system variables as well as in my configurations. I want to use "the system environment variable" to specify the path of my log file. Any more suggestion are welcome.
Regards, Jitendra -----Original Message----- From: Jacob Kjome [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 19, 2005 9:09 PM To: Log4J Users List Subject: RE: How to specify log file path using env variable 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
