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

Fixes for the LogicalThreadContext - NDC stack is wrong

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 1.3.0
    • Fix Version/s: 1.3.0
    • Component/s: Core
    • Labels:
      None

      Description

      This is related to issue number 455. (Link to github: https://github.com/apache/log4net/pull/12)

      I was playing around with this fix recently and came across some strange behavior.
      Imagine main method:

      main.cs
      using (LogicalThreadContext.Stacks["NDC"].Push("Start"))
      {
          // init all the stuff here
          _timer.TimerElapsed += TimerOnTimerElapsed;
      }
      

      An that would be it.

      When I am on the timer tick event I have another context:

      timer.cs
      using (LogicalThreadContext.Stacks["NDC"].Push("timer"))
      {
          Logger.Info("I am doing something here. Show me the context");
      }
      

      As a result expect to see the context of the timer like this: "timer",
      instead, I see: "Start timer"

      Is this correct behavior?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              maxim.cherednik Maxim Cherednik
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: