logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Schaft (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-435) Feature request: auto-delete older log files
Date Wed, 25 Nov 2015 10:01:11 GMT

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

Robert Schaft commented on LOG4J2-435:

Remko, I am not a big fan of documentation. Mainly because the documentation of problems and
details is often far away from the description of the xml.
>From my point of view, the xml must talk by itself. Therefore my suggestion that tries
to resemble the xml configuration of [RollingFileAppender|https://logging.apache.org/log4j/2.x/manual/appenders.html#RollingFileAppender]
Because of your decision, that Delete is not limited to rolled over files, from the users
perspective it is independent of the rollover strategy. It is even independent of the appender.
It is in fact not even an appender. Therefore logically the configuration might look like

<Configuration status="warn" name="MyApp" packages="">
    <DirectoryMonitoringCleaner name="logArchivePurger" baseDir="logs">
    <!-- attribute depth could have a default of 255 to avoid recursion. attribute follow_links
is false per default.-->
           <ModificationTimeFilter minAge="90d"/>
           <SizeBasedFilter minSize="100M" />
           <FileNameFilter glob="**/*.log.gz" />
           <ModificationTimeFilter minAge="7dT1h" />
           <FileNameFilter pattern="\d+-\d{2}/app-[/]*-\d+\.log.gz" />
           <ModificationTimeFilter minAge="7d" />
         <ModificationTimeFilter minAge="180d" />
           <FileNameFilter pattern="\d+-\d{2}/app-[/]*-\d+\.log.gz" />
             <FileNameFilter glob="**" />
             <ModificationTimeFilter minAge="30d" />
        <ModificationTimeBasedOrdering />
           <FileCount count="100">
           <AccumulatedFileSize size="10gb">
             <FileCount count="90">
             <AccumulatedFileSize size="9gb">
    <RollingFile name="RollingFile" fileName="logs/app.log"
        <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
        <TimeBasedTriggeringPolicy />
        <SizeBasedTriggeringPolicy size="250 MB"/>
    <Root level="error">
      <AppenderRef ref="RollingFile"/>

I did not comment the configuration because the xml must be comment enough. If you don't understand
elements and what they are doing, please tell me so.

> 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

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

View raw message