Package co.elastic.logging.log4j2
Interface MdcSerializer
public interface MdcSerializer
Interface for serializing MDC (Mapped Diagnostic Context) data from a
LogEvent.
Implementations must have a public no-argument constructor to allow dynamic instantiation.
-
Method Summary
Modifier and TypeMethodDescriptionvoidserializeMdc(org.apache.logging.log4j.core.LogEvent event, StringBuilder builder) Add MDC data for the give log event to the provided output string builder.
-
Method Details
-
serializeMdc
Add MDC data for the give log event to the provided output string builder. The output written to the string builder must be a valid JSON-object without the surrounding curly braces and with a trailing comma. If this MDC serializer does not append any content, no comma shall be added. For example, the serializer could output the following content: "foo":"bar","key":"value",- Parameters:
event- the log event to write the MDC content forbuilder- the output JSON string builder
-