We see this problem too.

For my two cents, I'd prefer twenty 50ms delays to one 1 second delay...in our 
app, 1 second is forever.
        Dave

-----Original Message-----
From: Mike Blake-Knox [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 16, 2004 2:29 PM
To: 'Log4NET Dev'
Subject: RollingFileAppender Renaming Robustness


I've been using Chainsaw to tail RollingFileAppender log files.  I've found
that the RollingFileAppender is quite sensitive if Chainsaw happens to have
the file open (for read) when RollingFileAppender tries to rename it.

I've put a single delay/retry into RollFile.  Here is a replacement for the
RollFile catch block:

                                catch(Exception ex)
                                {
                                        ErrorHandler.Error("Exception while
rolling file [" + fromFile + "] -> [" + toFile + "]", ex,
ErrorCodes.GenericFailure);

                                        // in case the exception was caused
by trying to rename the file at the moment Chainsaw happened to be reading
it
                                        // sleep for a second then try again
                                        Thread.Sleep(1000);
                                        try 
                                        {
                                                file.MoveTo(toFile);
                                                //
LogLog.Debug("RollingFileAppender: Retry succeeded");
        
ErrorHandler.Error("RollingFileAppender: Retry succeeded");
                                        }
                                        catch (Exception ex2)
                                        {
                                                ErrorHandler.Error("Retry
failed", ex2, ErrorCodes.GenericFailure);
                                        }

                                }

It uses System.Threading to delay one second.

I hope a single one second delay is tolerable.  It seems to make a great
improvement in the reliability of RollFile operation.

Mike Blake-Knox
email: [EMAIL PROTECTED]
TSYS Office: (706) 644-3643
cellphone: (706) 570-4641
 


Reply via email to