Top Description Methods
org.apache.logging.log4j.spi

public Interface ThreadContextMap

Known Direct Subinterfaces
org.apache.logging.log4j.spi.ThreadContextMap2
Known Direct Implementers
org.apache.logging.log4j.spi.DefaultThreadContextMap, org.apache.logging.log4j.spi.NoOpThreadContextMap
Imports
java.util.Map, org.apache.logging.log4j.ThreadContext

Service provider interface to implement custom MDC behavior for org.apache.logging.log4j.ThreadContext.

Since 2.8, ThreadContextMap implementations that implement the ReadOnlyThreadContextMap interface are accessible to applications via the ThreadContext#getThreadContextMap() method.

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Clears the context.

public boolean

Returns:

True if the key is in the context, false otherwise.
containsKey
(final String
The key to locate.
key
)

Determines if the key is in the context.

public String

Returns:

The value associated with the key or null.
get
(final String
The key to locate.
key
)

Gets the context identified by the key parameter.

public Map<String, String>

Returns:

a mutable copy of the context.
getCopy
()

Gets a non-null mutable copy of current thread's context Map.

public Map<String, String>

Returns:

an immutable context Map or null.
getImmutableMapOrNull
()

Returns an immutable view on the context Map or null if the context map is empty.

public boolean

Returns:

true if the Map is empty, false otherwise.
isEmpty
()

Returns true if the Map is empty.

public void
put(final String
The key name.
key
,
final String
The key value.
value
)

Puts a context value (the o parameter) as identified with the key parameter into the current thread's context map.

public void
remove(final String
The key to remove.
key
)

Removes the context identified by the key parameter.

Method Detail

clearback to summary
public void clear()

Clears the context.

containsKeyback to summary
public boolean containsKey(final String key)

Determines if the key is in the context.

Parameters
key:String

The key to locate.

Returns:boolean

True if the key is in the context, false otherwise.

getback to summary
public String get(final String key)

Gets the context identified by the key parameter.

This method has no side effects.

Parameters
key:String

The key to locate.

Returns:String

The value associated with the key or null.

getCopyback to summary
public Map<String, String> getCopy()

Gets a non-null mutable copy of current thread's context Map.

Returns:Map<String, String>

a mutable copy of the context.

getImmutableMapOrNullback to summary
public Map<String, String> getImmutableMapOrNull()

Returns an immutable view on the context Map or null if the context map is empty.

Returns:Map<String, String>

an immutable context Map or null.

isEmptyback to summary
public boolean isEmpty()

Returns true if the Map is empty.

Returns:boolean

true if the Map is empty, false otherwise.

putback to summary
public void put(final String key, final String value)

Puts a context value (the o parameter) as identified with the key parameter into the current thread's context map.

If the current thread does not have a context map it is created as a side effect.

Parameters
key:String

The key name.

value:String

The key value.

removeback to summary
public void remove(final String key)

Removes the context identified by the key parameter.

Parameters
key:String

The key to remove.