@ComponentProfile(summary="Add a mapped diagnostic context for logging; useful for filtering",
tag="service,logging,debug")
public class AddExtendedLoggingContext
extends ServiceImp
MDC.put(String, String).
It can be useful to use a mapped diagnostic context to provide additional information into your logfile if the underlying logging system supports it (e.g. logback or log4j2)
As the diagnostic logging context is thread based; bear in mind that you will lose the context if part of the service execution
chain contains a something like PoolingMessageSplitterService or similar (i.e. something with an underlying thread pool
that acts on the message).
This is designed to work in conjunction with LoggingContextWorkflowInterceptor as it will
add the following items based on object metadata, this is particular useful for above highlighted the scenario with PoolingMessageSplitterService.
In the adapter configuration file this class is aliased as add-extended-logging-context-service which is the preferred alternative to the fully qualified classname when building your configuration.
log| Constructor and Description |
|---|
AddExtendedLoggingContext() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeService() |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
java.lang.Boolean |
getUseDefaultKeys()
Return whether the default keys will be populated
|
KeyValuePairList |
getValuesToSet() |
protected void |
initService() |
void |
prepare()
Prepare for initialisation.
|
void |
setUseDefaultKeys(java.lang.Boolean useDefaultKeys)
Sets whether to write channel, workflow and message id into the Mapped Diagnostic Context based on object metadata.
|
void |
setValuesToSet(KeyValuePairList values)
Set the list of values to set
|
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stoppublic void doService(AdaptrisMessage msg) throws ServiceException
ServiceApply the service to the message.
msg - the AdaptrisMessage to processServiceException - wrapping any underlying Exceptionsprotected void initService()
throws CoreException
initService in class ServiceImpCoreExceptionprotected void closeService()
closeService in class ServiceImppublic void prepare()
throws CoreException
ComponentLifecycleExtensionCoreExceptionpublic KeyValuePairList getValuesToSet()
public void setValuesToSet(KeyValuePairList values)
values - the mapping to addpublic void setUseDefaultKeys(java.lang.Boolean useDefaultKeys)
Sets whether to write channel, workflow and message id into the Mapped Diagnostic Context based on object metadata. The following keys will be added:
useDefaultKeys - whether to populate the Mapped Diagnostic Contextpublic java.lang.Boolean getUseDefaultKeys()
Return whether the default keys will be populated