Monday, May 21, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: How rollingFileAppender works?
Prev Next
You are not authorized to post a reply.

Author Messages
Radovan Raszka

06/15/2009 2:26 PM  

Hello,
I am using log4net for a couple years, but it still have some secrets…
I'm using RollingFileAppender in my app and I'd like to limit number of stored log files - I wan't to keep logs for the last 10 days, any older log should be deleted.

First idea was to call once a day simple procedure, which finds all log files according its name and deletes all, which _creation_ date is older than 10 day. But it didn't work - first 10 day id nothing deleted what is OK, but then all files are deleted as all rolled files have the same creation date.

So I am wondering how file rolling really works? I expected that old file is reanmed and new file is created, but it isn't probably true.

Second idea is to delete old logs by other way - according documentation MaxsizeRollBackups may help. Has anybody experience with this settings? Of course I can try myself, but I need result today, I can not wait for 10 days :-(

Or is there any other way how to preserve only last 10 logfiles?

My config file:
<log4net>
        <appender name="Console" type="log4net.Appender.ConsoleAppender">
                <layout type="log4net.Layout.PatternLayout">
                        <!-- Pattern to output the caller's file name and line number -->
                        <conversionPattern value="%date{HH:mm:ss,fff} %5level [%thread] %message%n" />
                </layout>
                <Threshold value="DEBUG" />
        </appender>

        <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
                <appendToFile value="true" />
                <file value="Log/Service.log" />
                <layout type="log4net.Layout.PatternLayout">
                        <conversionPattern value="%date{HH:mm:ss,fff} %5level [%2thread] %message (%logger{1}:%line)%n" />

                        <!--<conversionPattern value="%date{HH:mm:ss,fff} %5level %message (%type{1}:%line)%n" />-->
                </layout>
                <rollingStyle value="Date" />
                <Threshold value="DEBUG" />
        </appender>

        <root>
                <level value="DEBUG" />
                <appender-ref ref="Console" />
                <appender-ref ref="RollingFile" />
        </root>
</log4net>

With regards
Radovan Raszka

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > How rollingFileAppender works?



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement