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

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

Hi Remko,

h5. Simple Example of LogList Configuration
The file based configuration might look like this:
{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" />
  <LogListCleanUpStrategy loglistpath="${sys:user.home}/logs/logs.list">
     <!-- The loglist is appended with each filename, which is created by the 
RolloverStrategy. If files are deleted, they are also removed from this list. 
-->
      <MaxFileAgeTrigger age="90d" /> <!-- will delete all files mentioned in 
logs.list, which modification time is older than 90 days and 0 seconds -->
      <TotalFileSizeTrigger size="100m" /> <!-- will delete the first files 
from logs.list until the total size of the remaining files is smaller or equal 
to 100MB -->
      <TotalFileCountTrigger count="110" /> <!-- will delete the first files 
from logs.list until only 110 files are remaining -->
  </LogLogCleanUpStrategy>
</RollingFile>
{code}

The loglistpath name could even default to RollingFile.fileName + ".list".
The file implicitly contains the order in which the files are created 
(modification timestamp is not required).
The file could be created manually if an administrator wants to use the feature 
in an existing project with existing log files.
The file contains the path names, which makes the directory walking and all 
related settings (depth, baseDir, file pattern) obsolete.
It is clear for the user what will happen next.

h5. ISO Duration
I could't find full ISO-Duration support in Java8. Either you choose Period and 
have to drop the hours, minutes and seconds or you choose Duration and have to 
drop the years, month and weeks. But in both cases (for 
[Period|https://docs.oracle.com/javase/8/docs/api/java/time/Period.html#parse-java.lang.CharSequence-]
 and 
[Duration|https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence-]
 you need the leading "P" and the "T". JSR 310 is a strange beast. I would 
stick with Joda for the duration.

> 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