I don't think that the bug has been fixed in a public version.
We patched it here, and I submitted the patch to the dev list, but it doesn't
look like it was incorporated.
I've attached the message I sent to the dev list
Dave
-----Original Message-----
From: Peter McEvoy [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 29, 2004 12:27 PM
To: Log4NET User
Subject: RE: Restarting app can cause logging to stop?
Thanks for the feedback. Although when restarting a web app, we just touch
the web.config: it's pretty hard to judge when the next hit will come in.
BTW, what version are you using? Will upgrading fix anything do you think?
Pete
> -----Original Message-----
> From: Dave Hutz [mailto:[EMAIL PROTECTED]
> Sent: 29 June 2004 17:21
> To: 'Log4NET User'
> Subject: RE: Restarting app can cause logging to stop?
>
>
> Yes, this happens to us pretty regularly. We found that
> introducing a delay of a few seconds between the stop and the
> start during the restart pretty much eliminates the problem.
>
> There is a bug logged for it in SourceForge(#872040). The
> root cause of that person's problem (permissions) is a little
> different than ours (file locking), but the solution is the same.
>
> Dave
>
> -----Original Message-----
> From: Peter McEvoy [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 29, 2004 12:03 PM
> To: [email protected]
> Subject: Restarting app can cause logging to stop?
>
>
> Folks,
> We are using log4net extensively in our applications which
> consist of a lot of windows services and web services.
> However we have spotted sometimes (only somtimes mind) that
> when a service is stopped and restarted, logging to the
> RollingLogFileAppender will completely stop; messages will
> not be written to the logfile any more, although messages
> _will_ get written to an EventLogAppender
>
> This is proving hard to reproduce, so I agree that this is
> little more than anecdotal, but I am wondering if anyone has
> seen this type of behaviour?
>
> We are using log4net-1.1
>
> Pete
>
--- Begin Message ---
We are encountering this issue sporadically when our application (a Windows
Service) is restarted.
I attached the methods I needed to change to correct the problem below (all
from FileAppender.cs).
I have a somewhat outdated code base, so it my require some minor changes to
include it.
We are also encountering another, similar problem when the file rolls over
(RollingFileAppender).
In short, we have some monitoring tools that periodically scan the log file for
errors. If one of them happens to be scanning the file at the exact instant
that it rolls over, the rename fails, but the re-open succeeds and the file is
truncated (since the scanning tool opens it with AllowReadWrite).
This causes us to lose an entire log file, which is unacceptable.
I am considering catching the specific exception which is thrown when the file
has been opened by another process and retrying until the lock clears. I think
delaying the rollover until next time something is logged would be a better
solution, but I don't see convenient way to do that.
Any thoughts?
Dave
/// <summary>
/// Closes any previously opened file and calls the parent's <see
cref="TextWriterAppender.Reset"/>.
/// </summary>
override protected void Reset()
{
base.Reset();
}
/// <summary>
/// This method determines if there is a sense in attempting to append.
/// </summary>
/// <remarks>
/// <para>
/// Checks if we should force the file to be open, and if so, tries
/// to open it is it isn't open
/// </para>
/// </remarks>
/// <returns><c>false</c> if any of the preconditions fail.</returns>
override protected bool PreAppendCheck()
{
if (m_qtw == null || m_qtw.Closed)
{
try
{
OpenFile(m_fileName, m_appendToFile);
}
catch(Exception e)
{
ErrorHandler.Error("OpenFile("+m_fileName+","+m_appendToFile+") call failed.",
e, ErrorCodes.FileOpenFailure);
}
}
return base.PreAppendCheck();
}
/// <summary>
/// Activate the options on the file appender. This will
/// case the file to be opened.
/// </summary>
override public void ActivateOptions()
{
base.ActivateOptions();
if (m_fileName != null)
{
try
{
OpenFile(m_fileName, m_appendToFile);
}
catch(Exception e)
{
ErrorHandler.Error("OpenFile("+m_fileName+","+m_appendToFile+") call failed.",
e, ErrorCodes.FileOpenFailure);
}
}
else
{
LogLog.Warn("FileAppender: File option not set for appender
["+Name+"].");
LogLog.Warn("FileAppender: Are you using FileAppender instead
of ConsoleAppender?");
}
}
--- End Message ---