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

MemoryAppender class is not thread safe

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.13
    • Fix Version/s: 1.2.14, 1.3.0
    • Component/s: Appenders
    • Labels:
      None
    • Environment:
      .NET Framework 4.0 (Full Profile)

      Description

      The memory appender cannot be used safely in an application that uses more than one thread to interact with logging.

      When using this code to retrieve and then clear events logged in the memory appender:
      var events = memoryAppender.GetEvents();
      memoryAppender.Clear();

      The executing thread may be preempted between these two calls and additional logging events logged. These events are then cleared when the thread resumes execution - and are never seen/processed.

      I expect to be be able to retrieve and clear the list of current events in one call that guarantees that no events are ever lost.

        Attachments

        1. MemoryAppenderTest.cs
          2 kB
          Gregory Babski
        2. MemoryAppender_ThreadSafety.diff
          2 kB
          Gregory Babski

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              babskig Gregory Babski
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: