Limiting the number of backups with time-triggered rollover

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Limiting the number of backups with time-triggered rollover

Bois, Bernard

Good day,

 

We are using the latest release of log4cxx (0.10.0).

 

I'd like to know if it is possible to specify a maximum number of backups when a time-triggered rollover policy is used.

 

It appears both classes supporting time-based rollovers (DailyRollingFileAppender and rolling::RollingFileAppender) do not have such an option.

The 'original' RollingFileAppender class does have a maximum number of backups but only supports size-based rollovers.

 

Thanks,

 

 

Bernard Bois

ARRIS

 

c +1 416 807 3136

 

Reply | Threaded
Open this post in threaded view
|

Re: Limiting the number of backups with time-triggered rollover

Jacob L. Anawalt-2
Hi,

On 2016-03-07 2:05 PM, Bois, Bernard wrote:
> I'd like to know if it is possible to specify a maximum number of backups when a
> time-triggered rollover policy is used.
>

I don't believe there is a default configuration that works like that.

Perhaps you could make a policy object that does rolling like the
FixedWindowRollingPolicy but uses the TriggeringPolicy from the
TimeBasedRollingPolicy.

> It appears both classes supporting time-based rollovers
> (DailyRollingFileAppender and rolling::RollingFileAppender) do not have such an
> option.
>

You need to look at the RollingPolicy implementation of
rolling::RollingFileAppender to find that. The FixedWindowRollingPolicy has a
max (and min) index used to rename a fixed number of backup files.

--
Jacob Anawalt
Gecko Software, Inc.
[hidden email]
435-752-8026
Reply | Threaded
Open this post in threaded view
|

Re: Limiting the number of backups with time-triggered rollover

Bois, Bernard
Hello Jacob,

This is a good tip, I will look into it.

Much thanks,
Bernard Bois
ARRIS

Sent from my iPhone

> On Mar 7, 2016, at 5:51 PM, "Jacob L. Anawalt" <[hidden email]> wrote:
>
> Hi,
>
>> On 2016-03-07 2:05 PM, Bois, Bernard wrote:
>> I'd like to know if it is possible to specify a maximum number of backups when a
>> time-triggered rollover policy is used.
>
> I don't believe there is a default configuration that works like that.
>
> Perhaps you could make a policy object that does rolling like the FixedWindowRollingPolicy but uses the TriggeringPolicy from the TimeBasedRollingPolicy.
>
>> It appears both classes supporting time-based rollovers
>> (DailyRollingFileAppender and rolling::RollingFileAppender) do not have such an
>> option.
>
> You need to look at the RollingPolicy implementation of rolling::RollingFileAppender to find that. The FixedWindowRollingPolicy has a max (and min) index used to rename a fixed number of backup files.
>
> --
> Jacob Anawalt
> Gecko Software, Inc.
> [hidden email]
> 435-752-8026