The configuration fragment assumes log4j 1.3.

log4j 1.2 had two rolling file appenders org.apache.log4j.RollingFileAppender which rolled on the next event after a file size limit was reached and org.apache.log4j.DailyRollingFileAppender which rolled on the next event after a date change. log4j 1.3 introduced a new framework which allowed user provided triggering policies (what to roll on) and rolling policies (how to name or rename files on a rollover). The old org.apache.log4j.RollingFileAppender and o.a.l.DailyRollingFileAppender are emulated using the new framework.

Log4j 1.3 would allow the flexibility to create a hybrid where both size and time were used as rolling criteria, but there is no such implementation at this time.

The max backup limit issue does not apply to time based rolling files since the rolled files do not need to be renamed. In the org.apache.log4j.RollingFileAppender, each rollover requires MyLog.0 to be renamed to MyLog.1, ... My Log.n-1 to MyLog.n so a large limit could result in a substantial amount of time being involved in renaming files.

If you are limited to log4j 1.2.x, use org.apache.log4j.DailyRollingFileAppender. If you are using log4j 1.3.x, use a fragment like the one provided. If daily rolling is not sufficient, you can extend the filename format to rollover more frequently.


On May 31, 2005, at 8:19 AM, OOMS DIRK wrote:

the below xml configuration works for me

  <appender name="PatternFileAppender"
class="org.apache.log4j.rolling.RollingFileAppender">
    <param name="Threshold" value="DEBUG"/>
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
      <param name="FileNamePattern"
value="/home/dirk/jakarta-tomcat-5.5.9/logs/myApp.log.%d{yyyy-MM- dd}.gz"/>
    </rollingPolicy>
    <layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{yyyy-MM-dd HH:mm:ss}, %p,
%c{1}] %m%n"/>
    </layout>
  </appender>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to