Kireet, you can find more details on the Jira ticket but to summarize, you need to configure a SizeBasedTriggeringPolicy for the %i pattern to be useful. If you do so, only "max" files are kept _within the same time period_.
On Sat, Feb 1, 2014 at 1:24 PM, Remko Popma <[email protected]> wrote: > Kireet, > > I can reproduce this and I've raised > https://issues.apache.org/jira/browse/LOG4J2-524 to track the issue. > I'll add comments to that Jira ticket as I make progress. > > Best regards, > Remko > > > On Sat, Feb 1, 2014 at 9:28 AM, Kireet <[email protected]> wrote: > >> I am trying to use the rolling file appender in log4j2, basically I want >> to roll at midnight daily and keep 3 old log files. New files are created >> properly, but log4j doesn't seem to be cleaning up the old files. Does >> log4j only support cleanup of files within the time period? Here is the >> relevant portion of the config. I tried things with and without the %i >> pattern. >> >> <RollingFile name="Event" fileName="app.log" >> filePattern="app-%d{yyyy-MM-dd}.%i.log"> >> <PatternLayout> >> <Pattern>%m%n</Pattern> >> </PatternLayout> >> <Policies> >> <TimeBasedTriggeringPolicy interval="1" modulate="true"/> >> </Policies> >> <DefaultRolloverStrategy compressionLevel="0" max="3"/> >> </RollingFile> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> >
