I worked on a solution to this that we are using in production... I posted it on the list without much response... You are welcome to try this...
http://article.gmane.org/gmane.comp.apache.logging.log4net.devel/885/match=rolling+files+date+time+boundaries+doesn't+support+maximum+number+backup On Tue, May 24, 2011 at 11:38 AM, Rob Richardson <rob.richard...@rad-con.com > wrote: > Thanks for your reply! I quote a reply to that thread below: > > > > I suspect the difficulties deleting files rolled only by date is that > the appender would need to take into account the DatePattern used when > locating files to be considered for deleting. Counted backups > (log.txt.1, log.txt.2, log.txt.3, etc.) are easier to deal with because > integer sequences are more well-known. > > I'm not aware of any efforts to support rolling of files based on > RollingMode.Date. > > > > I would be happy with counted backups, as mentioned in that reply. How do > I set my rolling file appender to do that? > > > > Thanks again! > > > > RobR > > > ------------------------------ > > *From:* Lansdaal, Michael T [mailto:michael.t.lansd...@boeing.com] > *Sent:* Tuesday, May 24, 2011 12:33 PM > *To:* Log4NET User > *Subject:* RE: Too many log files > > > > This post ( > http://www.l4ndash.com/Log4NetMailArchive%2Ftabid%2F70%2Fforumid%2F1%2Fpostid%2F17575%2Fview%2Ftopic%2FDefault.aspx) > says that maxSizeRollBackups does not work if you set RollingStyle to > RollingMode.Date (and another post I saw says it as “rollingStyle of Date > does not support maxSizeRollBackups). > > > > I have implemented my own directory cleaning code in application to clean > out log files older than a certain date. > > > > Thanks, Mike > > > > *From:* Rob Richardson [mailto:rob.richard...@rad-con.com] > *Sent:* Tuesday, May 24, 2011 8:37 AM > *To:* Log4NET User > *Subject:* Too many log files > > > > Log4net is ignoring the maximum number of files for my rolling file > appender: > > > > <appender name="RollingFile" type="log4net.Appender.RollingFileAppender"> > > <file value="HeatingModelScheduler.log" /> > > <appendToFile value="true" /> > > <param name="MaxSizeRollBackups" value="5" /> > > <param name="DatePattern" value=".yyyy-MM-dd.lo\g" /> > > <layout type="log4net.Layout.PatternLayout"> > > <conversionPattern value="%date - %message%newline" /> > > </layout> > > </appender> > > > > Why do I now have six old log files? > > > > Thank you very much. > > > > RobR >