public final class Slf4jMDCLogConfigurator extends Object implements LogDiagnosticsConfigurator
MDC based log configurator.
Configures log diagnostic context as String key and values
pairs. Context is supposed to appear in logging traces by the means
supported by Log4j. Context is maintained on a per thread basis.
Thread switching (like running task in ThreadPoolExecutor
or newly created Thread require explicit action in order to
transfer the context to the new thread and later clean it up.
MDC| Constructor and Description |
|---|
Slf4jMDCLogConfigurator() |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUpContext()
Clean the logging context for the current thread.
|
void |
cleanUpContext(Collection<String> keys)
Cleans specified keys from the logging context.
|
void |
configureContext(Map<String,String> diagCtx)
Configure logging context for the current thread.
|
Map<String,String> |
getContext()
Retrieve the logging context for the current thread
(
Thread.currentThread()). |
public void configureContext(Map<String,String> diagCtx)
LogDiagnosticsConfiguratorconfigureContext in interface LogDiagnosticsConfiguratordiagCtx - log diagnostics contextpublic void cleanUpContext()
LogDiagnosticsConfiguratorWARNING: this will clear the while underlying storage of the context, e.g. the slf4j MDC. It is possible that other data is stored in that storage, which is not supposed to be cleared. Use this method with caution, the vAPI infrastructure will never invoke it.
cleanUpContext in interface LogDiagnosticsConfiguratorpublic void cleanUpContext(Collection<String> keys)
LogDiagnosticsConfiguratorcleanUpContext in interface LogDiagnosticsConfiguratorkeys - the keys to be cleaned; must not be nullpublic Map<String,String> getContext()
LogDiagnosticsConfiguratorThread.currentThread()).
The result can be used to transfer the logging context to another thread, which continues the execution of the logical operation
getContext in interface LogDiagnosticsConfiguratorMap representing the log diagnostics contextCopyright © 2022. All rights reserved.