logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Deleting old logs
Date Fri, 19 Jun 2009 04:15:36 GMT

While this might not be the exact answer you were looking for, don't forget that sometimes
its easier to just write the 3 lines of code yourself for deleting old log files and move
on to other things:

foreach (string file in Directory.GetFiles("c:\\logs", "*.log"))
    if (DateTime.Today.Subtract(File.GetLastWriteTime(file)).Days > 10)

----- Original Message ----
From: M.Suarez <mocasu@gmail.com>
To: log4net-user@logging.apache.org
Sent: Monday, June 15, 2009 5:21:24 PM
Subject: Deleting old logs


I am trying to just have the latest 2 log files of my application, thus I
have configured the log4net as follows:

    <appender name="RollingFile"
      <file value="d:\netapps\logfiles\MyApp.log" />
      <appendToFile value="true" />
    <MaximumFileSize value="100KB"/>
    <MaxSizeRollBackups value="2" />
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />

      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger -
%message%newline" />

    <!-- Set root logger level to INFO and its only appender to Console and
      <level value="INFO" />
      <appender-ref ref="RollingFile" />

However, there will be more than then two expected log files, this is
"The maximum applies to each time based group of files and not the total" 

How should I configure log4net then to only store the latest two files? Any
help will be greatly appreciate it.

View this message in context: http://www.nabble.com/Deleting-old-logs-tp24042093p24042093.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

View raw message