-
-
Notifications
You must be signed in to change notification settings - Fork 340
Closed
Description
Hi team! It looks like b5f6ea2 broke NDC.Inherit(). By way of example:
var context = NDC.CloneStack();
NDC.Inherit(context);
Gives this error:
System.InvalidCastException : Unable to cast object of type 'System.Object[]' to type 'StackFrame[]'.
Stack Trace:
at log4net.Util.ThreadContextStack.set_InternalStack(Stack value) in /home/alle/git/apache/logging-log4net/src/log4net/Util/ThreadContextStack.cs:line 191
at log4net.NDC.Inherit(Stack stack) in /home/alle/git/apache/logging-log4net/src/log4net/NDC.cs:line 160
I understand that the use of NDC has been deprecated for some time, but from looking at the code it seems the intent of log4net 3 has been to maintain backwards compatibility, so I think this behavior is a bug.
(On a related note, is there an appropriate replacement for the above, other than writing my own custom copy mechanism to ThreadContext.Stacks["NDC"].Pop()
into some temporary array, and then later on .Push()
back onto the stack?)