@ComponentProfile(summary="Add a mapped diagnostic context for logging; useful for filtering", tag="service,logging,debug") public class AddLoggingContext 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).
In the adapter configuration file this class is aliased as add-logging-context-service which is the preferred alternative to the fully qualified classname when building your configuration.
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
AddLoggingContext() |
AddLoggingContext(java.lang.String key,
java.lang.String value) |
Modifier and Type | Method and Description |
---|---|
protected void |
closeService() |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
java.lang.String |
getKey() |
java.lang.String |
getValue() |
protected void |
initService() |
void |
prepare()
Prepare for initialisation.
|
void |
setKey(java.lang.String key)
Set the key for the mapped diagnostic context.
|
void |
setValue(java.lang.String value)
Set the value for the mapped diagnostic context.
|
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getLookupName, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setLookupName, setUniqueId, start, stop
public AddLoggingContext()
public AddLoggingContext(java.lang.String key, java.lang.String value)
public void doService(AdaptrisMessage msg) throws ServiceException
Service
Apply the service to the message.
msg
- the AdaptrisMessage
to processServiceException
- wrapping any underlying Exception
sprotected void initService() throws CoreException
initService
in class ServiceImp
CoreException
protected void closeService()
closeService
in class ServiceImp
public void prepare() throws CoreException
ComponentLifecycleExtension
CoreException
public java.lang.String getKey()
public void setKey(java.lang.String key)
key
- the key to setpublic java.lang.String getValue()
public void setValue(java.lang.String value)
Supports metadata resolution via InterlokMessage.resolve(String)
; and also the magic value $UNIQUE_ID$
which
places the unique-id as the value.
value
- the value to set