You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Holger Wiechert <ho...@business-logics.de> on 2002/12/07 18:23:40 UTC

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


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Ooops: Solved, sorry: using system variables in log4j config file not recognized in tomcat

Posted by Holger Wiechert <ho...@business-logics.de>.
To those that are interested:
I've had a spelling error - of course it has to be:

set JAVA_OPTS=-DCATALINA_HOME=%CATALINA_HOME%


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


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



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


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Solved, sorry: using system variables in log4j config file not recognized in tomcat

Posted by Holger Wiechert <ho...@business-logics.de>.
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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>