Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-616

NullReferenceException in FileAppender.LockingModelBase.CloseStream method

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.8
    • Fix Version/s: None
    • Component/s: Appenders
    • Labels:
      None

      Description

      We are using log4net in a multithreaded application. When running the application from Visual Studio with debugging, in rare occasions a NullReferenceException occurs in FileAppender.LockingModelBase in the CloseStream method:

      System.NullReferenceException: Object reference not set to an instance of an object.
      at log4net.Appender.FileAppender.LockingModelBase.CloseStream(Stream stream)
      at log4net.Appender.FileAppender.MinimalLock.ReleaseLock()
      at log4net.Appender.FileAppender.LockingStream.ReleaseLock()
      at log4net.Appender.FileAppender.CloseWriter()
      at log4net.Appender.TextWriterAppender.Reset()
      at log4net.Appender.FileAppender.Reset()
      at log4net.Appender.TextWriterAppender.OnClose()
      at log4net.Appender.FileAppender.OnClose()
      at log4net.Appender.AppenderSkeleton.Close()
      at log4net.Appender.AppenderSkeleton.Finalize()
      at log4net.Appender.RollingFileAppender.Finalize()

      Debugging with log4net source code revealed it's the stream parameter of the CloseStream method that is null. Without knowing the root cause why the value is already null here (shouldn't be the case), would it be possible to add a null check here?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Frank Nietzold Frank Nietzold
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: