Friday, May 18, 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: RollingFileAppender truncates logfile at midnight
Prev Next
You are not authorized to post a reply.

Author Messages
Moss, Barney

11/15/2005 10:51 AM  

I use the RollingFileAppender to write a logfile from a long-lived process.
It is configured with static logfile name and to roll by date:

                <appender name="LogfileAppender" type="log4net.Appender.RollingFileAppender">
                        <file  value="logs\\CAPS_DMS.log" />                   
                        <RollingStyle value="date" />
                        <StaticLogFileName value="true" />
                        <MaxSizeRollBackups value="10" />
                        <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
                        <layout type="log4net.Layout.PatternLayout">
                                <param name="ConversionPattern" value="%d [%t] %-5p %c{1} - %m%n" />
                        </layout>
                        <filter type="log4net.Filter.LevelRangeFilter">
                                <param name="LevelMin" value="DEBUG" />
                        </filter>
                        <filter type="log4net.Filter.DenyAllFilter" />
                </appender>            

The problem is that if the process happens to run over midnight (e.g. starts at 11pm, runs for 2 hours), the first message after midnight causes the logfile to be truncated without being renamed first.  The first message in the file is from just past midnight.

Is this a known bug?  I didn't find anything in the mail list archives.
-thanks, Barney Moss

==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.csfb.com/legal_terms/disclaimer_external_email.shtml

==============================================================================

Matthew Brown

11/15/2005 2:23 PM  
You should remove <StaticLogFileName value="true" /> . I think the documentation might be a little confusing, but in my experience, under this setting the RollingFileAppender will only write to that one file, and not make any backups.

Nicko Cadell

12/12/2005 5:43 PM  

Setting the StaticLogFileName property to true means that the current
file will be called 'CAPS_DMS.log' and will be renamed when the rolling
period is up. If StaticLogFileName is false then the current file will
already be named with the start of the date range period.

If the file is being overwritten rather than rolled at the date boundary
then it is likely that the app does not have permission to rename the
file. You should run with log4net internal debug enabled to see any
error messages that log4net encounters.

http://logging.apache.org/log4net/release/faq.html#internalDebug

Nicko

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > RollingFileAppender truncates logfile at midnight



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