Class MdcJsonProvider

  • All Implemented Interfaces:
    ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.LifeCycle, JsonProvider<ch.qos.logback.classic.spi.ILoggingEvent>

    public class MdcJsonProvider
    extends AbstractFieldJsonProvider
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String FIELD_MDC_PREFIX  
      • Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

        context
    • Constructor Summary

      Constructors 
      Constructor Description
      MdcJsonProvider()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addExclude​(java.lang.String key)  
      void addInclude​(java.lang.String key)  
      boolean canWrite​(ch.qos.logback.classic.spi.ILoggingEvent event)
      Indicates if this provider can write anything for a particular event.
      protected void writeExactlyOneField​(JsonEventWriter writer, ch.qos.logback.classic.spi.ILoggingEvent event)
      Write exactly one field into JSON event layout.
      boolean writeTo​(JsonEventWriter writer, ch.qos.logback.classic.spi.ILoggingEvent event, boolean startWithSeparator)
      Writes a certain aspect of event into a writer.
      • Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase

        addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface ch.qos.logback.core.spi.ContextAware

        addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
    • Field Detail

      • FIELD_MDC_PREFIX

        public static final java.lang.String FIELD_MDC_PREFIX
        See Also:
        Constant Field Values
    • Constructor Detail

      • MdcJsonProvider

        public MdcJsonProvider()
    • Method Detail

      • canWrite

        public boolean canWrite​(ch.qos.logback.classic.spi.ILoggingEvent event)
        Description copied from interface: JsonProvider
        Indicates if this provider can write anything for a particular event. If this method returns false, writeTo() should not be called for a particular event. You can put all your preliminary checks here, no need to duplicated them in writeTo().
        Specified by:
        canWrite in interface JsonProvider<ch.qos.logback.classic.spi.ILoggingEvent>
        Overrides:
        canWrite in class AbstractFieldJsonProvider
      • writeTo

        public boolean writeTo​(JsonEventWriter writer,
                               ch.qos.logback.classic.spi.ILoggingEvent event,
                               boolean startWithSeparator)
        Description copied from interface: JsonProvider
        Writes a certain aspect of event into a writer.
        Specified by:
        writeTo in interface JsonProvider<ch.qos.logback.classic.spi.ILoggingEvent>
        Overrides:
        writeTo in class AbstractFieldJsonProvider
        Parameters:
        writer - JSON writer to use.
        event - Current logback event.
        startWithSeparator - If true, a separator should be written before writing anything else.
        Returns:
        If anything was effectively written during this call.
      • addExclude

        public void addExclude​(java.lang.String key)
      • addInclude

        public void addInclude​(java.lang.String key)