RollingFileAppenders that log to a network share from a web application fail to 
resume logging in the event the network share is 
disconnected/reconnected/failsover
-------------------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: LOG4NET-103
                 URL: http://issues.apache.org/jira/browse/LOG4NET-103
             Project: Log4net
          Issue Type: Bug
          Components: Appenders
    Affects Versions: 1.2.10, 1.2.9
         Environment: Windows 2003, ASP.NET, C#
            Reporter: Kenneth Oberleitner


We have seen an issue when logging from our web applications to a clustered SAN 
which fails over to a backup. I have recreated the scenario locally with two 
machines and writing a log file to a network share.

1) Enabled internal logging in log4net to a local file on MACHINE-C 

2) Set up a share on MACHINE-B, and started a web application logging to that 
share from MACHINE-C; logs appeared on the share as expected 

3) Disabled the share on MACHINE-B, refreshed the web application, the 
following error was reported in log4net's internal debugging 

log4net:ERROR [RollingFileAppender] Failed in DoAppend 
System.IO.IOException: The handle is invalid. 

   at System.IO.__Error.WinIOError(Int32 errorCode, String str) 
   at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count) 
   at System.IO.FileStream.FlushWrite() 
   at System.IO.FileStream.Flush() 
   at log4net.Appender.LockingStream.Flush() 
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) 
   at System.IO.StreamWriter.Flush() 
   at log4net.Util.TextWriterAdapter.Flush() 
   at log4net.Appender.FileAppender.Append(LoggingEvent loggingEvent) 
   at log4net.Appender.RollingFileAppender.Append(LoggingEvent loggingEvent) 
   at log4net.Appender.AppenderSkeleton.DoAppend(LoggingEvent loggingEvent) 

4) Re-enabled the share on MACHINE-B, refreshed the web application; no logging 
appeared in the shared log file, and the following error appeared in log4nets 
internal debugging 

log4net:ERROR [RollingFileAppender] Failed in DoAppend 
System.ObjectDisposedException: Cannot access a closed file. 
   at System.IO.__Error.FileNotOpen() 
   at System.IO.FileStream.Write(Byte[] array, Int32 offset, Int32 count) 
   at log4net.Appender.LockingStream.Write(Byte[] buffer, Int32 offset, Int32 
count) 
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) 
   at System.IO.StreamWriter.Flush() 
   at log4net.Util.TextWriterAdapter.Flush() 
   at log4net.Appender.FileAppender.Append(LoggingEvent loggingEvent) 
   at log4net.Appender.RollingFileAppender.Append(LoggingEvent loggingEvent) 
   at log4net.Appender.AppenderSkeleton.DoAppend(LoggingEvent loggingEvent) 

5) Touched web.config, refreshed the web application; no logging appeared in 
the shared log file, and the following errors appeared in log4net's internal 
debugging 

log4net: Hierarchy: Shutdown called on Hierarchy [log4net-default-repository] 
log4net:ERROR [RollingFileAppender] Could not close writer 
[log4net.Util.CountingQuietTextWriter] 
System.ObjectDisposedException: Cannot access a closed file. 
   at System.IO.__Error.FileNotOpen() 
   at System.IO.FileStream.Flush() 
   at log4net.Appender.LockingStream.Flush() 
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) 
   at System.IO.StreamWriter.Dispose(Boolean disposing) 
   at System.IO.StreamWriter.Close() 
   at log4net.Util.TextWriterAdapter.Close() 
   at log4net.Util.QuietTextWriter.Close() 
   at log4net.Appender.TextWriterAppender.CloseWriter() 

... 

log4net:ERROR [RollingFileAppender] Unable to acquire lock on file 
\\MACHINE-B\Log\log-file.txt. The process cannot access the file 
"\\MACHINE-B\Log\log-file.txt" because it is being used by another process. 
log4net:ERROR [RollingFileAppender] OpenFile(\\MACHINE-B\Log\log-file.txt,True) 
call failed. 
LockStateException: The file is not currently locked 
   at log4net.Appender.LockingStream.AssertLocked() 
   at log4net.Appender.LockingStream.get_CanWrite() 
   at System.IO.StreamWriter..ctor(Stream stream, Encoding encoding, Int32 
bufferSize) 
   at System.IO.StreamWriter..ctor(Stream stream, Encoding encoding) 
   at log4net.Appender.FileAppender.OpenFile(String fileName, Boolean append) 
   at log4net.Appender.RollingFileAppender.OpenFile(String fileName, Boolean 
append) 
   at log4net.Appender.FileAppender.SafeOpenFile(String fileName, Boolean 
append) 

... 

log4net:ERROR [RollingFileAppender] Unable to acquire lock on file 
\\MACHINE-B\Log\log-file.txt. The process cannot access the file 
"\\MACHINE-B\Log\log-file.txt" because it is being used by another process. 
log4net:ERROR [RollingFileAppender] OpenFile(\\MACHINE-B\Log\log-file.txt,True) 
call failed. 
LockStateException: The file is not currently locked 
   at log4net.Appender.LockingStream.AssertLocked() 
   at log4net.Appender.LockingStream.get_CanWrite() 
   at System.IO.StreamWriter..ctor(Stream stream, Encoding encoding, Int32 
bufferSize) 
   at System.IO.StreamWriter..ctor(Stream stream, Encoding encoding) 
   at log4net.Appender.FileAppender.OpenFile(String fileName, Boolean append) 
   at log4net.Appender.RollingFileAppender.OpenFile(String fileName, Boolean 
append) 
   at log4net.Appender.FileAppender.SafeOpenFile(String fileName, Boolean 
append) 
log4net:ERROR [RollingFileAppender] No output stream or file set for the 
appender named [AppRollingFileAppender]. 


6) Performed an iisreset; logging then appeared in the shared log and no errors 
in the log4net internal debugging


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to