You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Manuel Teira <ma...@gmail.com> on 2014/04/09 09:57:56 UTC

Compressing only old rollover files

Hello all,

I'm evaluating a switch to log4j-2 since my application is required to
rollover files by age and size (for what the composite triggering policies
come handy). The rollover files shall also be compressed, but only those
reaching a given age.

What would be the preferred approach to achieve that using log4j-2? Should
be reasonable to write a custom rollover strategy or is there any other way
out-of-the box that may work?

Thanks and best regards,

Manuel.

Re: Compressing only old rollover files

Posted by "simon_park_mail@yahoo.co.uk" <si...@yahoo.co.uk>.
Hi Manuel, 

If you're currently using Log4J 1.2 then you could also consider using the TimeAndSizeRollingAppender, available from my site at www.simonsite.org.uk, as a stop-gap before moving to Log4J 2.0. 

Best Regards, 

Simon

Sent from Yahoo Mail on Android


Re: Compressing only old rollover files

Posted by Manuel Teira <ma...@gmail.com>.
Hi Ralph,

thanks for answering. Your understanding is right and that is exactly what
I'm trying to do: to control in a separate way rolling over and compression
(the customer prefers to have some of the more recent files uncompressed).

Nevertheless, I would prefer to make all the management of the log files
from  log4j itself, without any external tool involved. This is because I'm
scared about potential clashes between rollover and any
compression/renaming that could happen from the external tooling.

So, may be a custom rollover strategy the way to go?



2014-04-09 17:46 GMT+02:00 Ralph Goers <ra...@dslextreme.com>:

> Log4j currently compresses the files when it rolls them over. Of course
> you can cause that to happen based on time, but it sounds like you want the
> time of rollover and time of compression to be separate.  If so, I am not
> sure you really need to tie the compression activity to Log4j, or at least
> the appender at all.  You just need something that monitors the directory
> and looks for files over a certain age and then compresses them, deletes
> them, or whatever.
>
> If I've misunderstood what you are asking please let me know.
>
> Ralph
>
> On Apr 9, 2014, at 12:57 AM, Manuel Teira <ma...@gmail.com> wrote:
>
> > Hello all,
> >
> > I'm evaluating a switch to log4j-2 since my application is required to
> > rollover files by age and size (for what the composite triggering
> policies
> > come handy). The rollover files shall also be compressed, but only those
> > reaching a given age.
> >
> > What would be the preferred approach to achieve that using log4j-2?
> Should
> > be reasonable to write a custom rollover strategy or is there any other
> way
> > out-of-the box that may work?
> >
> > Thanks and best regards,
> >
> > Manuel.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: Compressing only old rollover files

Posted by Manuel Teira <ma...@gmail.com>.
That's exactly my fear regarding mixing the framework with external tools.
This seems an issue related to buffering though.

I'm wondering if it would be possible to avoid any of these problems by
choosing date based rollover names. Let's say that I pick the following
setup:
- Trigger rollover after 20Mb
- Trigger rollover every day
- Name the rollover files based on the date app.${yyyy-MM-dd}.log
- Maximum 10 rollover files

So, I understand the rollover will happen in case the log exceeds 20 Mb in
size and also after 00:00.
Is log4j-2 in this scenario able to keep only the last 10 rollover files?
How does it figure out what files should be removed?
What would happen if an external tool is compressing (and renaming) those
rollover files older than a given age? Is that affecting the way log4j-2 is
trying to keep only the 10 more recent rollover files?

Thanks a lot!



2014-04-10 1:33 GMT+02:00 Remko Popma <re...@gmail.com>:

> Be aware you can't combine the RandomAccessFile appenders with logrotate.
> See https://issues.apache.org/jira/browse/LOG4J2-354
>
> Sent from my iPhone
>
> > On 2014/04/10, at 7:58, Matt Sicker <bo...@gmail.com> wrote:
> >
> > It sounds like the "delaycompress" option from logrotate:
> > http://linux.die.net/man/8/logrotate
> >
> >
> >> On 9 April 2014 09:46, Ralph Goers <ra...@dslextreme.com> wrote:
> >>
> >> Log4j currently compresses the files when it rolls them over. Of course
> >> you can cause that to happen based on time, but it sounds like you want
> the
> >> time of rollover and time of compression to be separate.  If so, I am
> not
> >> sure you really need to tie the compression activity to Log4j, or at
> least
> >> the appender at all.  You just need something that monitors the
> directory
> >> and looks for files over a certain age and then compresses them, deletes
> >> them, or whatever.
> >>
> >> If I've misunderstood what you are asking please let me know.
> >>
> >> Ralph
> >>
> >>> On Apr 9, 2014, at 12:57 AM, Manuel Teira <ma...@gmail.com>
> wrote:
> >>>
> >>> Hello all,
> >>>
> >>> I'm evaluating a switch to log4j-2 since my application is required to
> >>> rollover files by age and size (for what the composite triggering
> >> policies
> >>> come handy). The rollover files shall also be compressed, but only
> those
> >>> reaching a given age.
> >>>
> >>> What would be the preferred approach to achieve that using log4j-2?
> >> Should
> >>> be reasonable to write a custom rollover strategy or is there any other
> >> way
> >>> out-of-the box that may work?
> >>>
> >>> Thanks and best regards,
> >>>
> >>> Manuel.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
> > --
> > Matt Sicker <bo...@gmail.com>
>

Re: Compressing only old rollover files

Posted by Remko Popma <re...@gmail.com>.
Be aware you can't combine the RandomAccessFile appenders with logrotate. See https://issues.apache.org/jira/browse/LOG4J2-354

Sent from my iPhone

> On 2014/04/10, at 7:58, Matt Sicker <bo...@gmail.com> wrote:
> 
> It sounds like the "delaycompress" option from logrotate:
> http://linux.die.net/man/8/logrotate
> 
> 
>> On 9 April 2014 09:46, Ralph Goers <ra...@dslextreme.com> wrote:
>> 
>> Log4j currently compresses the files when it rolls them over. Of course
>> you can cause that to happen based on time, but it sounds like you want the
>> time of rollover and time of compression to be separate.  If so, I am not
>> sure you really need to tie the compression activity to Log4j, or at least
>> the appender at all.  You just need something that monitors the directory
>> and looks for files over a certain age and then compresses them, deletes
>> them, or whatever.
>> 
>> If I’ve misunderstood what you are asking please let me know.
>> 
>> Ralph
>> 
>>> On Apr 9, 2014, at 12:57 AM, Manuel Teira <ma...@gmail.com> wrote:
>>> 
>>> Hello all,
>>> 
>>> I'm evaluating a switch to log4j-2 since my application is required to
>>> rollover files by age and size (for what the composite triggering
>> policies
>>> come handy). The rollover files shall also be compressed, but only those
>>> reaching a given age.
>>> 
>>> What would be the preferred approach to achieve that using log4j-2?
>> Should
>>> be reasonable to write a custom rollover strategy or is there any other
>> way
>>> out-of-the box that may work?
>>> 
>>> Thanks and best regards,
>>> 
>>> Manuel.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> -- 
> Matt Sicker <bo...@gmail.com>

Re: Compressing only old rollover files

Posted by Matt Sicker <bo...@gmail.com>.
It sounds like the "delaycompress" option from logrotate:
http://linux.die.net/man/8/logrotate


On 9 April 2014 09:46, Ralph Goers <ra...@dslextreme.com> wrote:

> Log4j currently compresses the files when it rolls them over. Of course
> you can cause that to happen based on time, but it sounds like you want the
> time of rollover and time of compression to be separate.  If so, I am not
> sure you really need to tie the compression activity to Log4j, or at least
> the appender at all.  You just need something that monitors the directory
> and looks for files over a certain age and then compresses them, deletes
> them, or whatever.
>
> If I’ve misunderstood what you are asking please let me know.
>
> Ralph
>
> On Apr 9, 2014, at 12:57 AM, Manuel Teira <ma...@gmail.com> wrote:
>
> > Hello all,
> >
> > I'm evaluating a switch to log4j-2 since my application is required to
> > rollover files by age and size (for what the composite triggering
> policies
> > come handy). The rollover files shall also be compressed, but only those
> > reaching a given age.
> >
> > What would be the preferred approach to achieve that using log4j-2?
> Should
> > be reasonable to write a custom rollover strategy or is there any other
> way
> > out-of-the box that may work?
> >
> > Thanks and best regards,
> >
> > Manuel.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
Matt Sicker <bo...@gmail.com>

Re: Compressing only old rollover files

Posted by Ralph Goers <ra...@dslextreme.com>.
Log4j currently compresses the files when it rolls them over. Of course you can cause that to happen based on time, but it sounds like you want the time of rollover and time of compression to be separate.  If so, I am not sure you really need to tie the compression activity to Log4j, or at least the appender at all.  You just need something that monitors the directory and looks for files over a certain age and then compresses them, deletes them, or whatever.  

If I’ve misunderstood what you are asking please let me know.

Ralph

On Apr 9, 2014, at 12:57 AM, Manuel Teira <ma...@gmail.com> wrote:

> Hello all,
> 
> I'm evaluating a switch to log4j-2 since my application is required to
> rollover files by age and size (for what the composite triggering policies
> come handy). The rollover files shall also be compressed, but only those
> reaching a given age.
> 
> What would be the preferred approach to achieve that using log4j-2? Should
> be reasonable to write a custom rollover strategy or is there any other way
> out-of-the box that may work?
> 
> Thanks and best regards,
> 
> Manuel.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org