Hi everybody,
sorry for my previous message: it looks like the solution Jake proposed works fine. The thing is I sent the post after having tested only from my IDE and when doing so it effectively contains a "/" in the filePath variable. On the contrary, if I execute my application directly from the Web Browser the logs are written to the file located in the path specified by logDir, which I previously defined as a parameter in the Java variables of the Tomcat monitor.

So it appears to me that when debuging or executing from my IDE, this uses its own Web application server rather than Tomcat. Moreover, this guesswork is confirmed when debugging/running the application from the IDE while Tomcat is stopped, because the applciation works.

So when debugging/running the application from the IDE, I should specify -DlogDir=C:\emedica\SEG_QUIM\aplicacion\filesystem\securequim\logs\ADMPAC in the Java Options of the "Run/Debug" tab in the Project Properties.

Thanks everybody for your help, and especially Jake and Curt.
Cheers,
JON HAITZ



Jacob Kjome escribió:

I think the problem might be that your command line contains spaces in your -D parameters, causing later ones not to be parsed correctly. Here's your -D parameters...

-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

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


Get rid of the spaces. I think you either need to quote the values with spaces or do something like using C:\Progra~1\ instead of C:\Program Files\. Better yet, install Tomcat to a directory without spaces. Actually, I recommend this for any and all java applications, including the JDK.


Jake

On Tue, 17 Jun 2008 13:59:40 +0200
 Jon Haitz Legarreta Gorroño <[EMAIL PROTECTED]> wrote:
Dear Jake,

thanks for the reply.

Unfortunately, the problem persists.

As for your your first suggestion, the directory,

C:\emedica\SEG_QUIM\aplicacion\filesystem\securequim\logs\ADMPAC

which is supposed to be the value of logDir, effectively exists. If I execute it in the Run->start window it heads well to the directory. I don't let log4j the task to create neither the whole nor part of it.

As for the second suggestion, I've used the -Dlog4j.debug=true option and it effectively yields some more information. However, we can see there that it clearly does not contain the desired path in the File token (log4j.appender.Appender.File=${logDir}/ADMPAC.log), and it does not provide me with further informations:


08/06/17 13:35:27 log4j: Using URL [file:/C:/Sources/SEG_QUIM/ADMPAC/public_html/WEB-INF/classes/log4j.properties] for automatic log4j configuration. 08/06/17 13:35:27 log4j: Reading configuration from URL file:/C:/Sources/SEG_QUIM/ADMPAC/public_html/WEB-INF/classes/log4j.properties 08/06/17 13:35:27 log4j: Parsing for [root] with value=[Level.DEBUG, Appender].
08/06/17 13:35:27 log4j: Level token is [Level.DEBUG].
08/06/17 13:35:27 log4j: Category root set to DEBUG
08/06/17 13:35:27 log4j: Parsing appender named "Appender".
08/06/17 13:35:27 log4j: Parsing layout options for "Appender".
08/06/17 13:35:27 log4j: Setting property [conversionPattern] to [%-5p %d{dd MMM yyyy HH:mm:ss} [%c] - %m%n].
08/06/17 13:35:27 log4j: End of parsing for "Appender".
08/06/17 13:35:27 log4j: Setting property [append] to [true].
08/06/17 13:35:27 log4j: Setting property [immediateFlush] to [true].
08/06/17 13:35:27 log4j: Setting property [contextKey] to [USER_ID].
08/06/17 13:35:27 log4j: Setting property [threshold] to [INFO].
08/06/17 13:35:27 log4j: Setting property [filePath] to [/].
08/06/17 13:35:27 log4j: Setting property [file] to [/ADMPAC.log].
08/06/17 13:35:27 log4j: setFile called: /ADMPAC.log, true
08/06/17 13:35:27 log4j: setFile ended
08/06/17 13:35:27 log4j: Parsed "Appender" options.
08/06/17 13:35:27 log4j: Setting category factory to [Logica.SegLoggerFactory].
08/06/17 13:35:27 log4j: Finished configuring.


I still haven't got a clue of where the problem comes from. Sorry.
Thanks for any help,
JON HAITZ





Jacob Kjome escribió:
Jon Haitz Legarreta Gorroño wrote:
Hi Jake,
thanks for your suggestion, but I am not saying that

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

does not work, I am saying that logDir is always empty .

If the directory corresponding to ${logDir} is always empty, I'd say that's the
definition of "does not work".

To verify
whether the way I define it is the correct one, please refer to point 1
to my first post.


Does the path actually exist? That is, does the ADMPAC directory actually exist or do you expect Log4j to create it? Log4j won't create directories (at least older versions.... this might have been corrected in more recent versions).

Other than that, try using -Dlog4j.debug=true in order to see what's being
configured.  Maybe it's picking up a different config file altogether?


Jake


Thanks for any help,
JON HAITZ




Jacob Kjome escribió:
On Tue, 03 Jun 2008 09:57:07 +0200
 Jon Haitz Legarreta Gorroño <[EMAIL PROTECTED]> wrote:
Hi again,
thanks for your answer Curt, but it did not fix the problem. I'm
still experiencing the same problems as yesterday.

Any other ideas?
You are saying that the following doesn't work for you?

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

That would be really surprising as I use this all the time and it has
never failed for me.

Jake

Thank you,
JON HAITZ



Curt Arnold escribió:
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]


--

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]


---------------------------------------------------------------------
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]



--

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]




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



--

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