views:

223

answers:

2

Hello,

We have an application that logs using log4net. But we would like to delete the logfiles every 4 weeks (automatically).
Is there an option in log4net to do this or do we need to have a work arround?

Cheers, M.

this is my configuration

<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
        <file value="Logs/Log4Net/"/>
    <appendToFile value="true"/>
    <rollingStyle value="Date"/>
        <staticLogFileName value="false" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <datePattern value="yyyy-MM-dd-HH.lo\g" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="1MB" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/>
    </layout>
  </appender>
  <root>
    <level value="ALL"/>
    <appender-ref ref="RollingFileAppender"/>
  </root>
+1  A: 

I would suggest you using the windows task scheduler for this job.

Darin Dimitrov
+4  A: 

If this answer doesn't help you, then you can also come up with a windows service that would do the purge-job.

KMan
omg this is great, thx mate.
Sem Dendoncker