logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject RE: Log4Net Threading Error?
Date Tue, 27 Sep 2005 18:23:40 GMT
A colleage encountered this same exception today. They had internal
logging enabled. When they turned off internal debugging the issue went
away. When internal debugging was turned on the problem re-appeared.
They're using a trace listener in the web.config to output log4net
debug messages to a file. I think they also mentioned that the file the
trace listenred was attempting to write did not have appropriate write
access (it did eariler in the week then something changed on the
server). I glanced at the log4net code and all calls to:

 Trace.Write(message)
 Console.Out.WriteLine(message)

are wrapped in a try/catch block. I'll try to get a Debug build up so I
can get line numbers...

Server Error in '/' Application.
Probable I/O race condition detected while copying memory. The I/O
package is not thread safe by
default. In multithreaded applications, a stream must be accessed in a
thread-safe way, such as a
thread-safe wrapper returned by TextReader's or TextWriter's
Synchronized methods. This also
applies to classes like StreamWriter and StreamReader.

Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.

Exception Details:
System.IndexOutOfRangeException: Probable I/O race condition detected
while copying memory. The I/O package is not thread safe by default. In
multithreaded applications, a stream must be accessed in a thread-safe
way, such as a thread-safe wrapper returned by TextReader's or
TextWriter's
Synchronized methods. This also applies to classes like StreamWriter
and StreamReader.

Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace
below.

Stack Trace:
[IndexOutOfRangeException: Probable I/O race condition detected while
copying memory. The I/O package is not thread safe by default. In
multithreaded applications, a stream must be ac
System.Buffer.InternalBlockCopy(Array src, Int32 srcOffset, Array dst,
Int32 dstOffset, Int32 count) +0
System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count)
+115
System.IO.TextWriter.WriteLine(String value) +207
System.IO.SyncTextWriter.WriteLine(String value) +26
log4net.Config.XmlConfigurator.ConfigureAndWatch(ILoggerRepository
repository, FileInfo configFile) +209
log4net.Config.XmlConfigurator.ConfigureAndWatch(FileInfo configFile)
+25

--- Nicko Cadell <nicko@neoworks.com> wrote:

> I think this is coming from a Console.Out.WriteLine call. As far as I
> am
> aware this should be thread safe, indeed looking at the exception
> stack
> it looks like Console.Out is a SyncTextWriter. My first guess is that
> this is a thread safety issue in the .NET core library :(
> 
> However log4net should not be chucking out this sort of exception.
> This
> was fixed as part of http://issues.apache.org/jira/browse/LOG4NET-26
> and
> will be part of the next release.
> 
> Out of interest is there a good reason that you are calling
> DOMConfigurator.Configure from WMService.Data.Oracle..ctor? If
> possible
> you should try to minimise the number of times you call
> DOMConfigurator.Configure. You should try to do it once at start-up
> rather during execution.
> 
> Cheers,
> Nicko
> 
> > -----Original Message-----
> > From: Stewart, Mark (GE Consumer Finance, consultant) 
> > [mailto:mstewart@wmcdirect.com] 
> > Sent: 06 July 2005 22:06
> > To: Log4NET User
> > Subject: Log4Net Threading Error?
> > 
> > I have gotten the following error in my log4net log.  This 
> > application can have multiple threads writing to the same log 
> > file.  The Message and the trace stack below point to log4net...  
> > Any comments or ideas?
> > (Using = VS.NET 2003, and log4net (1.2.0 Beta 9)
> > 
> > 
> > 2005-05-12 17:53:43,863 [1420] FATAL 
> > WMService.Control.Process [] - 
> > WMService.Service.ReceiveMessage() had an Exception
> > Exception: System.IndexOutOfRangeException
> > Message: Probable I/O race condition detected while copying 
> > memory.  The I/O package is not thread safe by default.  In 
> > multithreaded applications, a stream must be accessed in a 
> > thread-safe way, such as a thread-safe wrapper returned by 
> > TextReader's or TextWriter's Synchronized methods.  This also 
> > applies to classes like StreamWriter and StreamReader.
> > Source: mscorlib
> >    at System.Buffer.InternalBlockCopy(Array src, Int32 
> > srcOffset, Array dst, Int32 dstOffset, Int32 count)
> >    at System.IO.StreamWriter.Write(Char[] buffer, Int32 
> > index, Int32 count)
> >    at System.IO.TextWriter.WriteLine(String value)
> >    at System.IO.SyncTextWriter.WriteLine(String value)
> >    at log4net.helpers.LogLog.Debug(String msg)
> >    at 
> > log4net.Config.DOMConfigurator.Configure(ILoggerRepository
> repository)
> >    at log4net.Config.DOMConfigurator.Configure()
> >    at WMService.Data.Oracle..ctor()
> >    at WMService.Control.Process.ReceiveMessage(MessageQueue 
> > messageQueue)
> > 
> > 
> > Thanks,
> > Mark
> > 
> 


Mime
View raw message