Log4j Relative Path to Tomcat7 Log Directory File Not Found

Posted by Nik on Stack Overflow See other posts from Stack Overflow or by Nik
Published on 2012-09-11T15:36:53Z Indexed on 2012/09/11 15:37 UTC
Read the original article Hit count: 404

Filed under:
|
|
|

I have this log4j XML file:

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender name="gemFile" class="org.apache.log4j.RollingFileAppender"> 
        <param name="File" value="file:${catalina.home}/logs/GEM.log" />
        <param name="MaxBackupIndex" value="5" />
        <param name="MaxFileSize" value="3MB" />
        <param name="Append" value="true" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="[%t] %d{yyyy-MM-dd HH:mm:ss.SSS} %-5p %c{1} - %m%n" />
        </layout>
    </appender>
    <root> 
        <priority value ="info" /> 
        <appender-ref ref="gemFile" />
    </root>
</log4j:configuration>

${catalina.home} resolves to C:\Apps\Apache\Tomcat7. When I deploy my WAR file, I get

log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: file:C:\Apps\Apache\Tomcat7\logs\GEM.log (The filename, directory name, or volume label syntax is incorrect)
    stack trace...

It is true that the log file does not exist (the folder structure does), but if I set the file directly to that path (<param name="File" value="C:/Apps/Apache/Tomcat7/logs/GEM.log" />) it works fine. Why can't I use the replacement string?

© Stack Overflow or respective owner

Related posts about java

Related posts about spring