I had seen that, yes; I'm not sure it will help. What I really want to do is trigger (programmatically) a purge of old files (because I've added a DefaultRolloverStrategy with the max files set),
AFAICT the <delete> action will let me programmatically control which files are deleted (e.g. files older than some value set at runtime), but only during the rollover - so it may be some time before that happens (if at all, if the process is restarted frequently enough that the max size is never reached). The background to this is that we have a WAR file that is deployed to a number of different sites. The number of files we want to keep on each site can differ so rather than edit the XML file on each site each time we deploy a new version, there's a site specific configuration (with a pre-configured default) that is programatically applied. Perhaps there's a better way to do that. Greg PS. I can't see any documentation on supported values for the "language" attribute; is it just JavaScript and Groovy as per the docs, or are there others? PPS. Why is JavaScript capitalised, but not groovy? On 16 August 2016 at 16:45, Ralph Goers <[email protected]> wrote: > 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 <[email protected]> > 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 > >
