I'm pretty sure that configuration file would not work with log4j 1.3 either. org.apache.log4j.rolling.RollingFileAppender requires a nested triggeringPolicy (which determines when a roll occurs) and a nested rollingPolicy (which determines how files are named), though they can be both provided by a single class that implements both interfaces. From your configuration file, it appears that you want some combination of date and size based rolling, though neither log4j or log4cxx current provide that. If you were trying to specify a date based rolling, neither log4j or log4cxx support a MaxBackupIndex as it is very difficult to determine what files should be deleted for an arbitrary date pattern.

Here is an example of a o.a.l.RFA configured with time-based rolling policy (from the unit tests)

<appender name="ROLL" class="org.apache.log4j.rolling.RollingFileAppender"> <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"> <param name="fileNamePattern" value="output/test1-%d{yyyy-MM- dd_HH_mm_ss}"/>
    </rollingPolicy>

    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%c{1} - %m%n"/>
    </layout>     
  </appender>

and a sized based policy (from scratch so it might be a little buggy)

<appender name="ROLL" class="org.apache.log4j.rolling.RollingFileAppender"> <triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
                <param name="MaxFileSize" value="10KB" />
   </triggeringPolicy>
<rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
                <param name="FileNamePattern" value="/tmp/log.txt.%i"/>
                <param name="MaxIndex" value="10"/>
  </rollingPolicy>

    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%c{1} - %m%n"/>
    </layout>     
  </appender>



On May 9, 2007, at 5:54 AM, Jitendra Kharche wrote:


Hi,

I am using RollingFileAppender and my config file is as given below

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "./log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/";
debug="false" threshold="info">
        <appender name="APP_LOGFILE"
class="org.apache.log4j.rolling.RollingFileAppender">
                <errorHandler
class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
                <param name="File" value="/tmp/log.txt"/>
                <param name="Append" value="true"/>
                <param name="Threshold" value="info"/>
                <param name="DatePattern" value=".%Y-%m-%d"/>
                <param name="MaxFileSize" value="10KB" />
                <param name="MaxBackupIndex" value="10" />
                <layout class="org.apache.log4j.PatternLayout">
                        <param name="ConversionPattern" value="%d %-5p
[%c{1}] %m%n"/>
                </layout>
        </appender>

        <root>
                <appender-ref ref="APP_LOGFILE"/>
        </root>
</log4j:configuration>

But the log file is not getting rolled at all on AIX (and also on other
platforms). My application is a Java Web application that launches
multiple native executables that write log to this log file.

Any known reasons?

Regards,
Jitendra

Reply via email to