I have a log4cxx.xml configuration file which defines multiple rolling file appenders.
<?xml version="1.0" encoding="UTF-8" ?>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="A" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="file" value="file1.log" />
<param name="MaxFileSize" value="12MB" />
...
</appender>
...
<appender name="G" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="file" value="file7.log" />
<param name="MaxFileSize" value="12MB" />
...
</appender>
<!-- Loggers referencing A, B, ..., G -->
I would like to have one place, in the file, where I define the maximum file size. I know that I can replace 12MB with ${MAX_FILE_SIZE} and get the value from the environment, but I do not want to have to set an environment variable.
It seemed that the following should work.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration [
<!ENTITY maxFileSize "12MB">
]>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="A" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="file" value="file1.log" />
<param name="MaxFileSize" value="&maxFileSize" />
...
</appender>
...
However, this fails with log4cxx: Error parsing file [log4cxx.xml], Internal errorXML parser error code: not well-formed (invalid token) (4)
.
My guess as to what is going wrong is that either I got the DOCTYPE statement wrong, or log4cxx does not have a full XML parser and does not expect the DOCTYPE. I have little experience with DTDs, so both answers are plausible to me.
Is there a way to fix the DOCTYPE to make this work, or a completely different method that will get my desired result of specifying the maximum file size at one location in the file?