Log4j Relative Path to Tomcat7 Log Directory File Not Found
- by Nik
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?