On Jun 2, 2008, at 6:01 AM, Jon Haitz Legarreta Gorroño wrote:
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
Could you try again, but using forward slashes instead of back
slashes. log4j configuration has some unexpected treatment of
backslashes, but changing them could result in configurations that
depended on the old interpretation no longer working. However,
forward slashes do not have that issue and the Java run-time will
translate them to back slashes before calling Win32 API methods.
https://issues.apache.org/bugzilla/show_bug.cgi?id=22894
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]