Package org.apache.logging.log4j
Class CloseableThreadContext.Instance
java.lang.Object
org.apache.logging.log4j.CloseableThreadContext.Instance
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- CloseableThreadContext
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Removes the values from theThreadContext
.Pushes new diagnostic context information on to the Thread Context Stack.Pushes new diagnostic context information on to the Thread Context Stack.Populates the Thread Context Stack with the supplied stack.Populates the Thread Context Map with the supplied key/value pair.Populates the Thread Context Map with the supplied key/value pairs.
-
Method Details
-
push
Pushes new diagnostic context information on to the Thread Context Stack. The information will be popped off when the instance is closed.- Parameters:
message
- The new diagnostic context information.- Returns:
- the instance that will back out the changes when closed.
-
push
Pushes new diagnostic context information on to the Thread Context Stack. The information will be popped off when the instance is closed.- Parameters:
message
- The new diagnostic context information.args
- Parameters for the message.- Returns:
- the instance that will back out the changes when closed.
-
put
Populates the Thread Context Map with the supplied key/value pair. Any existing key in theThreadContext
will be replaced with the supplied value, and restored back to their original value when the instance is closed.- Parameters:
key
- The key to be addedvalue
- The value to be added- Returns:
- a new instance that will back out the changes when closed.
-
putAll
Populates the Thread Context Map with the supplied key/value pairs. Any existing keys in theThreadContext
will be replaced with the supplied values, and restored back to their original value when the instance is closed.- Parameters:
values
- The map of key/value pairs to be added- Returns:
- a new instance that will back out the changes when closed.
- Since:
- 2.8
-
pushAll
Populates the Thread Context Stack with the supplied stack. The information will be popped off when the instance is closed.- Parameters:
messages
- The list of messages to be added- Returns:
- a new instance that will back out the changes when closed.
- Since:
- 2.8
-
close
public void close()Removes the values from theThreadContext
.Values pushed to the
ThreadContext
stack will be popped off.Values put on the
ThreadContext
map will be removed, or restored to their original values it they already existed.- Specified by:
close
in interfaceAutoCloseable
-