That wouldn't be ideal for me as I have several different log files being produced in the same directory, but I do see how it would get pretty complicated to pattern match old files to delete selectively. I could separate things by folder I guess. What about at least filtering the files by everything up until the first pattern? E.g. for the below "app-%d{yyyy-MM-dd}.%i.log", what about only deleting files that start with app- and are older than the maxAge?

On 2/1/14 6:59 PM, Remko Popma wrote:
Agreed that this seems a common use case. Looking at the
LOG4J2-435<https://issues.apache.org/jira/browse/LOG4J2-435> ticket,
you're now the third person asking for this feature...

Team, what about adding a maxAge attribute to DefaultRolloverStrategy? The
attribute would accept values like "3d" (delete older than 3 days),
similarly "4w" (4 weeks), "5M" (5 months) etc.
The scanned directory would be the parent dir of the rolled over file
specified by the {{filePattern}} attribute, and any file in that directory
would be candidates for deletion.

Thoughts?


On Sunday, February 2, 2014, Arkin Yetis <[email protected]> wrote:

I had opened the following for this:
https://issues.apache.org/jira/browse/LOG4J2-435
Perhaps you can see if this would meet your need and vote for/watch it, if
it does.


On Sat, Feb 1, 2014 at 11:39 AM, Kireet <[email protected] <javascript:;>>
wrote:

Thanks for the update. So I would need to use an external process to
clean
up older files? This seems like a pretty common use case though right?



On 2/1/14 12:19 AM, Remko Popma wrote:

Kireet, you can find more details on the Jira ticket but to summarize,
you need to configure a SizeBasedTriggeringPolicy for the %i pattern to
be
useful.
If you do so, only "max" files are kept _within the same time period_.


On Sat, Feb 1, 2014 at 1:24 PM, Remko Popma <[email protected]<javascript:;>

wrote:

  Kireet,

I can reproduce this and I've raised
https://issues.apache.org/jira/browse/LOG4J2-524 to track the issue.
I'll add comments to that Jira ticket as I make progress.

Best regards,
Remko


On Sat, Feb 1, 2014 at 9:28 AM, Kireet <[email protected]<javascript:;>>
wrote:

  I am trying to use the rolling file appender in log4j2, basically I
want
to roll at midnight daily and keep 3 old log files. New files are
created
properly, but log4j doesn't seem to be cleaning up the old files. Does
log4j only support cleanup of files within the time period? Here is
the
relevant portion of the config. I tried things with and without the %i
pattern.

      <RollingFile name="Event" fileName="app.log"
                   filePattern="app-%d{yyyy-MM-dd}.%i.log">
        <PatternLayout>
          <Pattern>%m%n</Pattern>
        </PatternLayout>
        <Policies>
          <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
        </Policies>
        <DefaultRolloverStrategy compressionLevel="0" max="3"/>
      </RollingFile>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]<javascript:;>
For additional commands, e-mail: 
[email protected]<javascript:;>






---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]<javascript:;>
For additional commands, e-mail: 
[email protected]<javascript:;>






---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to