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

James Hutton commented on LOG4J2-656:
-------------------------------------

Honestly this is a big item.  There are a lot of conditions, do you want to 
only support date expiration by path replacement? Do you want to support 
access/modified time?  Both have some complexities.  I have written a plugin 
rollover policy (and you can too!) that does something similar, but it meets 
specific requirements for the company I'm employed with.

I do agree that a cron job is the easiest, quickest way forward.  However, as 
in my case, if the environment is a highly locked down enterprise environment 
shared by other applications/groups there are usually hoops and hurdles for 
permissions of a cron script to modify log data (write/delete).

That said, one of the biggest improvements of 2.x over 1.2.x is the plugin 
system.  I do think that if this was picked up by core that there are a few api 
additions (ie not for the GA) such as exposing fields from the RollingAppender 
through the RollingFileManager (getFilePattern()).  I'll see if i can replicate 
something and post a plugin here.  But again it has specific behaviors:  
* It archives files (compress) to an archive folder pattern, then purges from 
that folder.
* Only supports days as a unit of measurement. 
* Uses the dreaded concurrent executors package to have file io occur behind 
the scenes.
* Determines age of files based upon last datetime format in log files to be 
archived.
* Uses file age (lastModified) to determine purging
* does not delete empty archive folders (could use a extra check).


> How to delete rolled over folder older than six months.
> -------------------------------------------------------
>
>                 Key: LOG4J2-656
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-656
>             Project: Log4j 2
>          Issue Type: Question
>          Components: Appenders
>    Affects Versions: 2.0-rc1
>         Environment: Java 7
>            Reporter: sivan
>             Fix For: 2.0-rc1
>
>
> My application is using Rolling file appender. So the log files are daily 
> rolled over to the folder having name yyyy-MM. ie 2014-03, 2014-04, 2014-05 
> etc. Now the requirement is to delete 6 months older folder from the path.
> Is there any configuration to achieve this?
> The current configuration is as below.
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration>
>       <properties>
>               <property name="logPattern">%c|%K{sessionId}|%t|%d{MM/dd/yyyy 
> HH:mm:ss.SSS}|%p|%C|%M|%L|%K{msg}%n</property>
>               <property 
> name="filePattern">${sys:logfilepath}//$${date:yyyy-MM}//${sys:oft.appserver}-out-%d{yyyy-MM-dd}.log</property>
>               <property 
> name="fileName">${sys:logfilepath}//${sys:oft.appserver}-out.log</property>
>       </properties>
>       <appenders>
>               <Console name="Console" target="SYSTEM_OUT">
>                       <PatternLayout pattern="logPattern"/>
>               </Console>
>               <RollingFile name="RollingFile" fileName="${fileName}" 
> filePattern="${filePattern}">
>                       <PatternLayout>
>                               <pattern>${logPattern}</pattern>
>                       </PatternLayout>
>                       <Policies>
>                               <TimeBasedTriggeringPolicy />
>                       </Policies>
>               </RollingFile>
>       </appenders>
>       <loggers>
>               <AsyncLogger name="logtype" level="info" includeLocation="true" 
> additivity="false">
>                       <AppenderRef ref="RollingFile"/>
>               </AsyncLogger>
>               <root level="info">
>                       <AppenderRef ref="Console"/>
>               </root>
>       </loggers>
> </configuration>



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
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