Hi there,
I'm experiencing many problems with the log file path while trying to use a relative file path. I've got a Web application written in Java and powered by Tomcat. The thing is I'm doing my development in a Windows machine and so far I've hard-coded the path I want my log file to be written. But the application is intended to be deployed in a Linux machine and therefore the log file path is bound to change. So far, I'm writing both paths in my log4j.properties file and commenting the one I don't need in each situation:

log4j.appender.Appender.File=C:\\emedica\\SEG_QUIM\\aplicacion\\filesystem\\securequim\\logs\\ADMPAC\\ADMPAC.log
#log4j.appender.Appender.File=/home/securequim/logs/ADMPAC/ADMPAC.log

Now, this is not very practical and I think it could be improved.
The way to improve it, I guess, is by specifying a variable to be used in the log4j.properties file, the same as ${cataline.home} or ${user.home}. Now what I do is the following:

1. I right-click in the Apache Tomcat icon in the notification area of Windows and choose "Configure...". I then go to the "Java" tab and in the "Java Options", which already contains the following:

-Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 5.0
-Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\endorsed
-Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 5.0

I add:

-DlogDir=C:\emedica\SEG_QUIM\aplicacion\filesystem\securequim\logs\ADMPAC

in my Windows machine.

2. In my log4j.properties file I substitute the absolute hard-coded path with the following line:

log4j.appender.Appender.File=${logDir}\\ADMPAC.log

3. Much to my surprise, my log file is written in my root directory (C:\) !!! I've been debugging the application and it seems as though either Tomcat or the JVM (I don't know which of the does the operation) do not recognise the logDir variable: the fileName variable contains a bacsklash.

4. Even more surprising: the same happens when I use ${catalina.home} !!!


I've been reading lots of Web pages on this, but apparently none was the right one... Any help would be highly appreciated.

Thanks,
JON HAITZ


--

Jon Haitz Legarreta Gorroño
Laguntzaile zientifikoa / Colaborador científico / Scientific collaborator

VICOMTech - Visual Interaction and Communication Technologies Center
Mikeletegi Pasealekua, 57 - Parque Tecnológico
E-20009 Donostia - San Sebastián, Spain
Tel: +[34] 943 30 92 30
Fax: +[34] 943 30 93 93
e-mail: [EMAIL PROTECTED]
http://www.vicomtech.org

*** member of INI-GraphicsNet ****
http://www.inigraphics.net
*** member of IK4 Research Alliance ****
http://www.ik4.es

-----------------------------------------------------
VICOMTech is an ISO 9001:2000 certified institute
-----------------------------------------------------


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

Reply via email to