[ 
https://issues.apache.org/jira/browse/LOG4J2-435?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15028067#comment-15028067
 ] 

Remko Popma commented on LOG4J2-435:
------------------------------------

Interesting discussion. I agree with Ralph that scripts will provide the most 
power and flexibility to users, but I think a small set of predefined 
conditions for common use cases would be useful so that users don't have to 
reinvent the wheel each time. Common conditions would include:

* IfLastModified - matches files whose age exceeds the specified duration
* IfFileName - matches files whose name matches the glob or regex (I just 
discovered 
[PathMatcher|https://docs.oracle.com/javase/7/docs/api/java/nio/file/PathMatcher.html]
 so I can throw out my custom code)
* IfAll, IfAny, IfNot - composite conditions

Robert's use case of keeping the most recent files up to some number of files 
or total file size is interesting. It requires sorting the files before passing 
them to the conditions, which is also useful (or even necessary?) for a future 
script condition. The only problem I had was finding clear names that explain 
what these conditions do. (Robert, note that the term Filter already means 
[something different|http://logging.apache.org/log4j/2.x/manual/filters.html] 
in log4j.)
I am going to settle on IfAccumulatedFileSize and IfAccumulatedFileCount, 
respectively.

As discussed, the Delete element can be nested in the DefaultRolloverStrategy 
element (so it is triggered with each rollover), or in the ScheduledItem 
element that Ralph just added.

> Feature request: auto-delete older log files 
> ---------------------------------------------
>
>                 Key: LOG4J2-435
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-435
>             Project: Log4j 2
>          Issue Type: Improvement
>            Reporter: Arkin Yetis
>            Assignee: Remko Popma
>              Labels: Rollover
>             Fix For: 2.5
>
>         Attachments: LimitingRolloverStrategy.java, SizeParser.java
>
>
> Original description:
> {quote}
> DefaultRolloverStrategy max attribute only applies if you have a %i in the 
> file pattern. This request is to enhance DefaultRolloverStrategy or another 
> appropriate component to allow a max number of files limit to apply across 
> days/months/years when a filePattern includes a date pattern.
> {quote}
> ----
> One of the most requested features is to add the ability to Log4j to "clean 
> up" older log files.  This usually means deleting these files, although it 
> could also mean moving them to a different location, or some combination of 
> these. 
> Users have different requirements for selecting the files to clean up. A 
> common request is the ability to keep the last X number of log files. This 
> works well if rollover is only date based but may give undesired results with 
> size based rollover. 
> Another factor to consider is that the directory containing the log files may 
> contain the log files for multiple appenders, or even files unrelated to 
> logging. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org

Reply via email to