Class EcsEncoder

java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.encoder.EncoderBase<ch.qos.logback.classic.spi.ILoggingEvent>
co.elastic.logging.logback.EcsEncoder
All Implemented Interfaces:
ch.qos.logback.core.encoder.Encoder<ch.qos.logback.classic.spi.ILoggingEvent>, ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.LifeCycle

public class EcsEncoder extends ch.qos.logback.core.encoder.EncoderBase<ch.qos.logback.classic.spi.ILoggingEvent>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent>
     

    Fields inherited from class ch.qos.logback.core.encoder.EncoderBase

    started

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

    context
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected void
    addCustomFields(ch.qos.logback.classic.spi.ILoggingEvent event, StringBuilder builder)
    Subclasses can override this to add custom fields.
    void
    This method has been removed in logback 1.2.
    void
    This method has been removed in logback 1.2.
    byte[]
    encode(ch.qos.logback.classic.spi.ILoggingEvent event)
     
    byte[]
     
    byte[]
     
    void
    This method has been removed in logback 1.2.
    void
    setEventDataset(String eventDataset)
     
    void
    setIncludeMarkers(boolean includeMarkers)
     
    void
    setIncludeOrigin(boolean includeOrigin)
     
    void
    setMessageLayout(ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> messageLayout)
    The supplied Layout will be applied specifically to format the message field based on the logging event.
    void
    setServiceEnvironment(String serviceEnvironment)
     
    void
    setServiceName(String serviceName)
     
    void
    setServiceNodeName(String serviceNodeName)
     
    void
    setServiceVersion(String serviceVersion)
     
    void
    setStackTraceAsArray(boolean stackTraceAsArray)
     
    void
    setThrowableConverter(ch.qos.logback.classic.pattern.ThrowableHandlingConverter throwableConverter)
     
    void
     

    Methods inherited from class ch.qos.logback.core.encoder.EncoderBase

    isStarted, stop

    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 Details

    • messageLayout

      protected ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> messageLayout
  • Constructor Details

    • EcsEncoder

      public EcsEncoder()
  • Method Details

    • headerBytes

      public byte[] headerBytes()
    • start

      public void start()
      Specified by:
      start in interface ch.qos.logback.core.spi.LifeCycle
      Overrides:
      start in class ch.qos.logback.core.encoder.EncoderBase<ch.qos.logback.classic.spi.ILoggingEvent>
    • init

      public void init(OutputStream os)
      This method has been removed in logback 1.2. To make this lib backwards compatible with logback 1.1 we have implement this method.
    • doEncode

      public void doEncode(Object event) throws IOException
      This method has been removed in logback 1.2. To make this lib backwards compatible with logback 1.1 we have implement this method. However, since we compile with 1.2.x, this method is not compiled as an interface method, which means that there won't be type erasure. Therefore, we must use a Object argument for it to be compatible with 1.1.x.
      Throws:
      IOException
    • close

      public void close() throws IOException
      This method has been removed in logback 1.2. To make this lib backwards compatible with logback 1.1 we have implement this method.
      Throws:
      IOException
    • encode

      public byte[] encode(ch.qos.logback.classic.spi.ILoggingEvent event)
    • addCustomFields

      protected void addCustomFields(ch.qos.logback.classic.spi.ILoggingEvent event, StringBuilder builder)
      Subclasses can override this to add custom fields. The last character in the StringBuilder will be comma when this is called. You must add a comma after each custom field.
    • footerBytes

      public byte[] footerBytes()
    • setServiceName

      public void setServiceName(String serviceName)
    • setServiceVersion

      public void setServiceVersion(String serviceVersion)
    • setServiceEnvironment

      public void setServiceEnvironment(String serviceEnvironment)
    • setServiceNodeName

      public void setServiceNodeName(String serviceNodeName)
    • setIncludeMarkers

      public void setIncludeMarkers(boolean includeMarkers)
    • setStackTraceAsArray

      public void setStackTraceAsArray(boolean stackTraceAsArray)
    • setIncludeOrigin

      public void setIncludeOrigin(boolean includeOrigin)
    • addAdditionalField

      public void addAdditionalField(AdditionalField pair)
    • setEventDataset

      public void setEventDataset(String eventDataset)
    • setThrowableConverter

      public void setThrowableConverter(ch.qos.logback.classic.pattern.ThrowableHandlingConverter throwableConverter)
    • setMessageLayout

      public void setMessageLayout(ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> messageLayout)
      The supplied Layout will be applied specifically to format the message field based on the logging event.
      Parameters:
      messageLayout -