X Conversion Character

Reports the MDC (mapped diagnostic context) that is associated with the thread that generated the log event.
Alias: properties
Requirements: The key must be enclosed in a pair of braces.
If you specify a default value, you must specify key and default, separated by “ | “ (the vertical bar), enclosed in a pair of braces.

Syntax

X {key}
X {key | default}

Required Arguments

default
specifies the value that is used when the information that is specified by key cannot be found. The value of default is a character string that appears between | (the vertical bar) and }( the closing bracket).
Note If the character string contains quotation marks, the quotation marks become part of the value of default. Quotation marks in an XML attribute must be specified using the character entity ".
Example %X{clientNumber}|clientNumberNotFound}
key
specifies a parameter that is used to identify the portion of the log to retrieve using MDC.

Details

MDC is used to distinguish interleaved log output from different sources. Log output is typically interleaved when a server manages multiple clients in parallel. The MDC is managed on a per-thread basis.
The X conversion character must be followed by the key for the map. The value in the MDC that corresponds to the key is reported.

Example

Here is an example of the X conversion character:
%X{clientNumber}, where clientNumber is the key.