logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doal Miller <Doal.Mil...@mir3.com>
Subject Question about using org.apache.log4j.rolling.RollingFileAppender
Date Mon, 15 Mar 2010 23:48:44 GMT
I've been playing around with the RollingFileAppender out of the extra jar and I've gotten
it working in a couple of different ways but I'm not getting exactly what I want.

What I want is to roll a file when the maximum size is reached and to keep a large number
of files around, like around 250. With my following configuration file it rolls at 10,000
bytes but the FixedWindowRollingPolicy doesn't allow me to keep over 12 files. If I try to
set MaxIndex higher than 12 it complains and resets it. I tried using the TimeBasedRollingPolicy
instead, in conjunction with SizeBasedTriggeringPolicy but I guess TimeBasedRollingPolicy
uses its own triggering policy.

Is there a way to set the max number of files for the FixedWindowRollingPolicy to 250 without
cracking open the code?

Thanks in advance for any suggestions.


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
<log4j:configuration debug="true">
  <appender name="DebugLog" class="org.apache.log4j.rolling.RollingFileAppender">

    <rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
      <param name="ActiveFileName" value="logs/be-debug.log"/>
      <param name="FileNamePattern" value="logs/be-debug.log.%i.gz"/>
      <param name="MinIndex" value="1"/>
      <param name="MaxIndex" value="12"/>
    </rollingPolicy>

    <triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
      <param name="MaxFileSize" value="10000"/>
    </triggeringPolicy>

    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{DATE} %-5p [%t] %-17c{2} (%13F:%L) - %m\r\n"/>
    </layout>
  </appender>
  <root>
    <priority value="error"></priority>
    <appender-ref ref="DebugLog"/>
  </root>
</log4j:configuration>

Doal Miller
Sr. Software Engineer


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message