7

I only want log4net to keep let's say 10 days-worth of log files as keeping them growing indefinitely will eventually eat up my disk space. I had thought that I could do this by setting

<maxSizeRollBackups value="10" />

on my RollingFileAppender but no dice. How do I do this?

skaffman
  • 398,947
  • 96
  • 818
  • 769
George Mauer
  • 117,483
  • 131
  • 382
  • 612

2 Answers2

10

Take a look at this similar post for answers.

Make sure you are not rolling the logs by Date as per the SDK:

A maximum number of backup files when rolling on date/time boundaries is not supported.

Community
  • 1
  • 1
Sanjay Sheth
  • 1,539
  • 1
  • 9
  • 9
  • Thanks, though I don't necessarily need date/time boundaries, file number boundaries or total size boundaries will do just fine. – George Mauer Jul 13 '09 at 21:29
0

This is what exactly I am looking for.

Maybe this will help?

<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logfile" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<datePattern value="yyyyMMdd" />
<maxSizeRollBackups value="10" />
<layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>

Sml004
  • 495
  • 1
  • 7
  • 15