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 Type
    Method
    Description
    void
    serializeMdc(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

      void serializeMdc(org.apache.logging.log4j.core.LogEvent event, StringBuilder builder)
      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 for
      builder - the output JSON string builder