On May 23, 2006, at 10:05 AM, LECHNER Martin wrote:
I try to figure aut how to configure the MaxBackupIndex property
with an xml
config file.
The file looks like below and it does not work.
Any suggestions?
<appender name="RootFileApp" class="RollingFileAppender">
<param name="File" value="log_root.txt" />
<param name="append" value="false" />
<param name="MaxBackupIndex" value="5" />
<triggeringPolicy
class="org.apache.log4j.SizeBasedTriggeringPolicy">
<param name="MaxFileSize" value="10KB"/>
</triggeringPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d[%t] %-5p %c %x - %
m %n"/>
</layout>
</appender>
Best regards
ML
<winmail.dat>
log4cxx implements the log4j 1.3 style rolling file appender (that is
org.apache.log4j.rolling.RollingFileAppender vs
org.apache.log4j.RollingFileAppender). We haven't reworked the XML
configuration reader so it could support two different classes with
name that differ only in package name.
Your configuration file looks like a mix of o.a.l.RFA configuration
and o.a.l.r.RFA configuration. MaxBackupIndex is used by o.a.l.RFA
and triggeringPolicy by o.a.l.r.RFA.
Unfortunately, there is not a test in either log4j or log4cxx that
contains an example of setting up a size based o.a.l.r.RFA. I think
this sample is closer (and likely works for log4j), but I haven't
tested it with log4cxx.
<appender name="RootFileApp"
class="org.apache.log4j.rolling.RollingFileAppender">
<rollingPolicy
class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
<param name="maxIndex" value="5"/>
</rollingPolicy>
<triggeringPolicy
class="org.apache.log4j.SizeBasedTriggeringPolicy">
<param name="MaxFileSize" value="10KB"/>
</triggeringPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d[%t] %-5p %c %x - %m
%n"/>
</layout>
<param name="file" value="log_root.txt"/>
<param name="append" value="false"/>
</appender>