logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Holger Wiechert" <holger.wiech...@business-logics.de>
Subject Solved, sorry: using system variables in log4j config file not recognized in tomcat
Date Sat, 07 Dec 2002 18:28:35 GMT
Sorry, I should have been looking up the list first.
Just found out why it doesn't work. I forgot to include
the JVM property CATALINA_HOME in JAVA_OPTS:

set JAVA_OPTS=%-DCATALINA_HOME=%CATALINA_HOME%

Holger


-----Urspr√ľngliche Nachricht-----
Von: Holger Wiechert [mailto:holger.wiechert@business-logics.de]
Gesendet: Samstag, 7. Dezember 2002 18:24
An: log4j-user@jakarta.apache.org
Betreff: using system variables in log4j config file not recognized in
tomcat


I wonder about the reason that setting up a FileAppender
using a system variable causes an initialization error
for log4j when used in tomcat (Tomcat 4.1.12).
I have the log4j.properties (see below) in the classes dir
(packed in the application's war file).

The line:
log4j.appender.RFA.File=${CATALINA_HOME}/logs/myfile.log

should define the out file for the RollingFileAppender as:

C:\j\jakarta\Tomcat-4.1.12\logs\myfile.log

But, for some reason, I get the following tomcat error message:

log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: \logs\koll.log (The system cannot find the
path specified)
        at java.io.FileOutputStream.openAppend(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:174)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
        at org.apache.log4j.FileAppender.setFile(FileAppender.java:272)
        at
org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:156)
        at
org.apache.log4j.FileAppender.activateOptions(FileAppender.java:151)
        at
org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:247)
        ...

The system variable CATALINA_HOME is set correctly, so the path
C:\j\jakarta\Tomcat-4.1.12\logs\ exists.


The log4j.properties file is as follows:

log4j.rootLogger=DEBUG, stdout, RFA

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Threshold=DEBUG
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p: [%d] %c{2} - %m%n

log4j.appender.RFA=org.apache.log4j.RollingFileAppender
log4j.appender.RFA.File=${CATALINA_HOME}/logs/myfile.log
log4j.appender.RFA.MaxFileSize=200KB
log4j.appender.RFA.MaxBackupIndex=10
log4j.appender.RFA.Append=true
log4j.appender.RFA.layout=org.apache.log4j.PatternLayout
log4j.appender.RFA.layout.ConversionPattern=%5p: [%d] %c{2} - %m%n


When I use no directory part for the file definition:
log4j.appender.RFA.File=myfile.log

the log file is created in tomcat's bin directory (where the
catalina.bat resides).

Does anybody have an idea, how to set the file using system
variables?

I'm using W2k, JDK 1.4.1, Tomcat 4.1.12, Log4J 1.2.7.
Thanks in advance,
Holger

P.S.: Please send a CC to holger.wiechert@web.de since I have
no list subscription.





____________
Virus checked by G DATA AntiVirusKit
Virus news: www.antiviruslab.com



____________
Virus checked by G DATA AntiVirusKit
Virus news: www.antiviruslab.com


--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


Mime
View raw message