Class RegexFilteringMdcEntryWriter

java.lang.Object
net.logstash.logback.composite.loggingevent.mdc.RegexFilteringMdcEntryWriter
All Implemented Interfaces:
MdcEntryWriter

public class RegexFilteringMdcEntryWriter extends Object implements MdcEntryWriter
Writes MDC entries by delegating to other instances of MdcEntryWriter if MDC key matches the given include and exclude pattern.
  1. An MDC entry is written if the MDC key does match the includeMdcKeyPattern AND does not match the excludeMdcKeyPattern.
  2. Omitting a includeMdcKeyPattern means to include all MDC keys.
  3. Omitting a excludeMdcKeyPattern means to exclude no MDC keys.
  • Constructor Details

    • RegexFilteringMdcEntryWriter

      public RegexFilteringMdcEntryWriter()
  • Method Details

    • writeMdcEntry

      public boolean writeMdcEntry(JsonGenerator generator, String fieldName, String mdcKey, String mdcValue) throws IOException
      Description copied from interface: MdcEntryWriter
      Writes the given MDC entry allowing to manipulate the output of the field name and field value.
      Specified by:
      writeMdcEntry in interface MdcEntryWriter
      Parameters:
      generator - the generator to write the entry to.
      fieldName - the field name to use when writing the entry.
      mdcKey - the key of the MDC map entry.
      mdcValue - the value of the MDC map entry.
      Returns:
      true if this MdcEntryWriter handled the output of the entry, otherwise return false.
      Throws:
      IOException
    • getIncludeMdcKeyPattern

      public Pattern getIncludeMdcKeyPattern()
    • setIncludeMdcKeyPattern

      public void setIncludeMdcKeyPattern(String includeMdcKeyPattern)
    • getExcludeMdcKeyPattern

      public Pattern getExcludeMdcKeyPattern()
    • setExcludeMdcKeyPattern

      public void setExcludeMdcKeyPattern(String excludeMdcKeyPattern)
    • getMdcEntryWriters

      public List<MdcEntryWriter> getMdcEntryWriters()
    • addMdcEntryWriter

      public void addMdcEntryWriter(MdcEntryWriter mdcEntryWriter)