You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Jathy <xu...@yahoo.com> on 2008/10/10 12:01:42 UTC

Does TimeBasedRollingPolicy work with MaxBackupIndex?

I used TimeBasedRollingPolicy of RollingFileAppender to rollover log file
every minute. And at the same time I'd like to use MaxBackupIndex to set the
max number of backup files. But MaxBackupIndex does not work.
TimeBasedRollingPolicy cannot work with MaxBackupIndex or my configuration
file has some wrong? I attached my configuration:

<?xml version="1.0" encoding="UTF-8" ?> 
<log4j:configuration xmlns:log4j='http://logging.apache.org/' debug="true">
  <appender name="ROLLING"
class="org.apache.log4j.rolling.RollingFileAppender">
            <rollingPolicy
class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
              
            </rollingPolicy>
    
    <layout class="org.apache.log4j.PatternLayout">
      
    </layout>
    
  </appender>
  <root>
    <level value="INFO"/>
    <appender-ref ref="ROLLING"/>
  </root>
</log4j:configuration>
-- 
View this message in context: http://www.nabble.com/Does-TimeBasedRollingPolicy-work-with-MaxBackupIndex--tp19915414p19915414.html
Sent from the Log4cxx - Users mailing list archive at Nabble.com.


Re: Does TimeBasedRollingPolicy work with MaxBackupIndex?

Posted by Dale King <da...@gmail.com>.
I thought we already went over this. No, you cannot use both of them
together. Think about how this would work. When log4cxx rolls over, how it
would it figure out files that it should delete. Anything you come up with
will be a hack and not reliable. For SizeBasedRollingPolicy it has an easy
way to figure out which files to delete. There is a file name pattern where
it deletes the one with the max backup index in the filename and renames the
others one number higher. There is no easy way to do this with time based
rolling.


On Fri, Oct 10, 2008 at 6:01 AM, Jathy <xu...@yahoo.com> wrote:

>
> I used TimeBasedRollingPolicy of RollingFileAppender to rollover log file
> every minute. And at the same time I'd like to use MaxBackupIndex to set
> the
> max number of backup files. But MaxBackupIndex does not work.
> TimeBasedRollingPolicy cannot work with MaxBackupIndex or my configuration
> file has some wrong? I attached my configuration:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <log4j:configuration xmlns:log4j='http://logging.apache.org/'
> debug="true">
>  <appender name="ROLLING"
> class="org.apache.log4j.rolling.RollingFileAppender">
>            <rollingPolicy
> class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
>
>            </rollingPolicy>
>
>    <layout class="org.apache.log4j.PatternLayout">
>
>    </layout>
>
>  </appender>
>  <root>
>    <level value="INFO"/>
>    <appender-ref ref="ROLLING"/>
>  </root>
> </log4j:configuration>
> --
> View this message in context:
> http://www.nabble.com/Does-TimeBasedRollingPolicy-work-with-MaxBackupIndex--tp19915414p19915414.html
> Sent from the Log4cxx - Users mailing list archive at Nabble.com.
>
>


-- 
Dale King