Class AddExtendedLoggingContext
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,ConfigComment
,MessageEventGenerator
,Service
,StateManagedComponent
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
.
- channelid
- workflowid
- messageuniqueid
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.
-
Field Summary
Fields inherited from class com.adaptris.core.ServiceImp
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
doService
(AdaptrisMessage msg) Apply the service to the message.Return whether the default keys will be populatedprotected void
void
prepare()
Prepare for initialisation.void
setUseDefaultKeys
(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 setMethods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getComments, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setComments, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
-
Constructor Details
-
AddExtendedLoggingContext
public AddExtendedLoggingContext()
-
-
Method Details
-
doService
Description copied from interface:Service
Apply the service to the message.
- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s
-
initService
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
closeService
protected void closeService()- Specified by:
closeService
in classServiceImp
-
prepare
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
getValuesToSet
-
setValuesToSet
Set the list of values to set- Parameters:
values
- the mapping to add
-
setUseDefaultKeys
Sets whether to write channel, workflow and message id into the Mapped Diagnostic Context based on object metadata. The following keys will be added:
- channelid
- workflowid
- messageuniqueid
- Parameters:
useDefaultKeys
- whether to populate the Mapped Diagnostic Context
-
getUseDefaultKeys
Return whether the default keys will be populated
- Returns:
- whether the default keys will be populated
-