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 16:52:11 GMT

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

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

Ralph,

technically you want to design a condition that triggers only on some files.
It would be nice if you can tell us what conditions that might be, that are not covered by
the current filter possibilities.

Let's assume it is something strange that's not reasonable to be supported by the standard:
odd file size (e.g. 1 byte or 477bytes).
You could still write your class
{code:java}
package org.apache.log4j.deleter;
class OddSizeCondition implements FileBasedDeleterCondition {
  @Override
  public boolean deletable(File file) {
    return file.length() % 2 == 1;
  }
}
{code}

And your xml config:
{code:xml}
<Delete basePath="${sys:user.home}/logs" sort="MostRecentFirst" maxDepth="2">
  <OddSizeCondition>
</Delete>
{code}

> 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-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message