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

Robert Schaft commented on LOG4J2-435:
--------------------------------------

Hi Remko,
I have some remarks:

h3. ISO8601 Duration
Why do you want to ignore months and years? That is for my case the interesting 
timespan. I assume you want to work around the "M" ambiguity if you make the 
"T" optional: 3m -> 3 minutes or 3 months? I think it is not worth it. Live 
with the "P" and "T" and throw nice explaining exceptions to avoid inventing 
yet another duration format and parser which is similar but not equal to 
ISO8601. Using strict ISO8601 makes parsing and documentation easier and 
clearer what you want.

h3. File List Based Triggers
Problems for the triggers in this category: you need an ordering of the files 
and they are hard to combine with the <And> pattern because it can't be applied 
to only a single file but works on an ordered list of files.
h4. Total File Size
I am missing the crucial total file size based trigger: delete files until the 
sum of all log files are smaller than x - that's the main goal
h4. Total File Count
I am missing the total file count based trigger: delete files until only x 
files are left (limits the total size in combination with 
SizeBasedTriggeringPolicy).

h3. Logical Grouping
I understand that the <Delete> element is logically ordered inside the 
RolloverStrategy because it should only delete files created by that 
RolloverStrategy. A nice side effect would be, that the clean up could be 
triggered by a rollover.
But the proposed configuration makes is possible to delete files everywhere:
{code:xml}
 <RollingFile name="RollingFile" fileName="${sys:user.home}/logs/app.log" 
filePattern="${sys:user.home}/logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
  <DefaultRolloverStrategy stopCustomActionsOnError="true">
    <!-- custom action executed asynchronously after the rollover -->
    <Delete basePath="/var/log" maxDepth="2" followLinks="false">
      <And>
        <IfFileName path="*/*.gz" /> <!-- delete only files matching this 
pattern -->
      </And>
    </Delete> 
  </DefaultRolloverStrategy>
</RollingFile>
{code}
So the choice might be to let <Delete> stand outside the 
DefaultRolloverStrategy or limit the files to those created by the rollover 
strategy.

h3. Ordering
Ordering (as required by File List Based Triggers) by Modification Timestamp 
relies heavily on a file system feature, which might be supported and 
unreliably emulated (see 
[JavaDoc|http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#getLastModifiedTime(java.nio.file.Path,%20java.nio.file.LinkOption...)]).
It's better than nothing but I have the impression that the log file list based 
approach is more stable.


> 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