Package org.jboss.logmanager
Class NDC
- java.lang.Object
-
- org.jboss.logmanager.NDC
-
public final class NDC extends java.lang.Object
Nested diagnostic context. This is basically a thread-local stack that holds a string which can be included in a log message.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
NDC.Holder
private static class
NDC.Stack<T>
-
Field Summary
Fields Modifier and Type Field Description private static NDC.Holder
ndc
-
Constructor Summary
Constructors Modifier Constructor Description private
NDC()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
clear()
Clear the thread's NDC stack.static java.lang.String
get()
Get the current NDC value.static java.lang.String
get(int n)
Provided for compatibility with log4j.static int
getDepth()
Get the current NDC stack depth.static java.lang.String
pop()
Pop the topmost value from the NDC stack and return it.static int
push(java.lang.String context)
Push a value on to the NDC stack, returning the new stack depth which should later be used to restore the stack.static void
trimTo(int size)
Trim the thread NDC stack down to no larger than the given size.
-
-
-
Field Detail
-
ndc
private static final NDC.Holder ndc
-
-
Method Detail
-
push
public static int push(java.lang.String context)
Push a value on to the NDC stack, returning the new stack depth which should later be used to restore the stack.- Parameters:
context
- the new value- Returns:
- the new stack depth
-
pop
public static java.lang.String pop()
Pop the topmost value from the NDC stack and return it.- Returns:
- the old topmost value
-
clear
public static void clear()
Clear the thread's NDC stack.
-
trimTo
public static void trimTo(int size)
Trim the thread NDC stack down to no larger than the given size. Used to restore the stack to the depth returned by apush()
.- Parameters:
size
- the new size
-
getDepth
public static int getDepth()
Get the current NDC stack depth.- Returns:
- the stack depth
-
get
public static java.lang.String get()
Get the current NDC value.- Returns:
- the current NDC value, or
""
if there is none
-
get
public static java.lang.String get(int n)
Provided for compatibility with log4j. Get the NDC value that isn
entries from the bottom.- Parameters:
n
- the index- Returns:
- the value or
null
if there is none
-
-