Class AbstractFieldCollectionJsonProvider<V,​E,​T extends java.util.Collection<E>>

  • Type Parameters:
    V - Type of the field value supported by this provider.
    E - Type of key-value entry served by this provider.
    T - Type of key-value collection served by this provider.
    All Implemented Interfaces:
    ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.LifeCycle, JsonProvider<ch.qos.logback.classic.spi.ILoggingEvent>
    Direct Known Subclasses:
    KeyValuePairsJsonProvider, MdcJsonProvider

    public abstract class AbstractFieldCollectionJsonProvider<V,​E,​T extends java.util.Collection<E>>
    extends AbstractJsonProvider
    An abstract provider that writes a collection of JSON fields
    • Field Summary

      • Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

        context
    • Method Summary

      All Methods Instance Methods Abstract 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 abstract T extractEntries​(ch.qos.logback.classic.spi.ILoggingEvent event)
      Extract the collection of entries (i.e.
      protected abstract java.lang.String extractKey​(E entry)
      Extract the key (i.e.
      protected abstract V extractValue​(E entry)
      Extract the value (i.e.
      java.lang.String getPrefix()  
      boolean isNoPrefix()  
      void setNoPrefix​(boolean noPrefix)  
      void setPrefix​(java.lang.String prefix)  
      protected abstract void writeField​(JsonEventWriter writer, java.lang.String fieldName, V fieldValue)
      Write a 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
    • Constructor Detail

      • AbstractFieldCollectionJsonProvider

        public AbstractFieldCollectionJsonProvider()
    • 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().
      • 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.
        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.
      • extractEntries

        protected abstract T extractEntries​(ch.qos.logback.classic.spi.ILoggingEvent event)
        Extract the collection of entries (i.e. fields) from the logging event.
        Parameters:
        event - Current logback event.
      • extractKey

        protected abstract java.lang.String extractKey​(E entry)
        Extract the key (i.e. field name) from the collection entry.
      • extractValue

        protected abstract V extractValue​(E entry)
        Extract the value (i.e. field value) from the collection entry.
      • writeField

        protected abstract void writeField​(JsonEventWriter writer,
                                           java.lang.String fieldName,
                                           V fieldValue)
        Write a field into JSON event layout.
        Parameters:
        writer - JSON writer to use.
        fieldName - Name of the field to write.
        fieldValue - Value of the field to write.
      • addExclude

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

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

        public java.lang.String getPrefix()
      • setPrefix

        public void setPrefix​(java.lang.String prefix)
      • isNoPrefix

        public boolean isNoPrefix()
      • setNoPrefix

        public void setNoPrefix​(boolean noPrefix)