log4net SDK Reference |

# NDC.SetMaxDepth Method

Forces the stack depth to be at most maxDepth.

[Visual Basic]
Public Shared Sub SetMaxDepth( _
ByVal maxDepth As Integer _
)
[C#]
public static void SetMaxDepth(
int maxDepth
);

#### Parameters

maxDepth
  The maximum depth of the stack

#### Remarks

> Note

> The NDC is deprecated and has been replaced by the Stacks. The current NDC implementation forwards to the `ThreadContext.Stacks["NDC"]`.

Forces the stack depth to be at most maxDepth. This may truncate the head of the stack. This only affects the stack in the current thread. Also it does not prevent it from growing, it only sets the maximum depth at the time of the call. This can be used to return to a known context depth.

#### See Also

NDC Class | log4net Namespace