Have you looked at http://logging.apache.org/log4j/2.x/manual/appenders.html#Log_Archive_Retention_Policy:_Delete_on_Rollover <http://logging.apache.org/log4j/2.x/manual/appenders.html#Log_Archive_Retention_Policy:_Delete_on_Rollover>?
Ralph > On Aug 16, 2016, at 6:53 AM, Greg Thomas <greg.d.tho...@gmail.com> wrote: > > Is it possible to programatically trigger a purge? > > I've got an XML configured appender along the lines of ... > > <Appenders> > <RollingFile name="rfappender" fileName="../logs/output.log" > filePattern="../logs/output.%i.log.zip"> > <PatternLayout> > <pattern>%d %-5p [%c{1}] %X - %m%n</pattern> > </PatternLayout> > <Policies> > <OnStartupTriggeringPolicy /> > <SizeBasedTriggeringPolicy size="100 MB"/> > </Policies> > </RollingFile> > </Appenders> > > > i.e. create new log file on startup, and when the current one reaches > 100MB. There is no "max" number of files to keep > > I've also got, in code, something that adds a DefaultRolloverStrategy with > the maximum number of files to keep. However, because we already created a > new file (appender.log.nn.zip) on startup, we've probably already exceeded > that number, so I'd like to purge it immediately. > > I can't see a way to do that - any ideas? > > Thanks, > > Greg