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 Adrian Beech <a....@bigpond.net.au> on 2003/08/11 12:42:08 UTC

Creating log files relative to the web applications root directory?

G'day,

Is it possible to specify a log filename in the XML log4j properties file so
that it is relative to the web applications root directory?

I have the following in a log4j.xml file located in web-inf/classes with the
log4j jar in the web-inf/lib directory.  Logging seems to be fine except the
"rascal.log" file is being created in the Tomcat application directory under
C:\Program Files\ and not in the C:\Tomcat 4.1\webapps\... Directory tree.
I'd prefer to have the log files in something like
../webapps/<application>/logs/<logfilename>.  Is this possible?

BTW, took a while to find the rascal.log file!!!

--[log4j.xml]---------------------------------------------------------
?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration>

    <appender name="rf" class="org.apache.log4j.RollingFileAppender">
        <param name="file" value="rascal.log"/>
        <param name="maxBackupIndex" value="2"/>
        <param name="maxFileSize" value="250KB"/>

        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{dd/MM/yyyy HH:mm:ss}
%-5p (%t) %l - %m%n"/>
        </layout>
    </appender>

    <root>
        <priority value="debug" />
        <appender-ref ref="rf"/>
    </root>

</log4j:configuration>
--[End Of File]-------------------------------------------------------

I'm using Tomcat 4.1.24 on a Win XP and 2k box for development and Tomcat
4.1.24 on a Unix box as the production platform.

AB



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