Class CompositeJsonEncoder<Event extends DeferredProcessingAware>

java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.encoder.EncoderBase<Event>
net.logstash.logback.encoder.CompositeJsonEncoder<Event>
All Implemented Interfaces:
Encoder<Event>, ContextAware, LifeCycle, StreamingEncoder<Event>
Direct Known Subclasses:
AccessEventCompositeJsonEncoder, LoggingEventCompositeJsonEncoder

public abstract class CompositeJsonEncoder<Event extends DeferredProcessingAware> extends EncoderBase<Event> implements StreamingEncoder<Event>
  • Constructor Details

    • CompositeJsonEncoder

      public CompositeJsonEncoder()
  • Method Details

    • createFormatter

      protected abstract AbstractCompositeJsonFormatter<Event> createFormatter()
    • encode

      public void encode(Event event, OutputStream outputStream) throws IOException
      Specified by:
      encode in interface StreamingEncoder<Event extends DeferredProcessingAware>
      Throws:
      IOException
    • encode

      public byte[] encode(Event event)
      Specified by:
      encode in interface Encoder<Event extends DeferredProcessingAware>
    • start

      public void start()
      Specified by:
      start in interface LifeCycle
      Overrides:
      start in class EncoderBase<Event extends DeferredProcessingAware>
    • stop

      public void stop()
      Specified by:
      stop in interface LifeCycle
      Overrides:
      stop in class EncoderBase<Event extends DeferredProcessingAware>
    • headerBytes

      public byte[] headerBytes()
      Specified by:
      headerBytes in interface Encoder<Event extends DeferredProcessingAware>
    • footerBytes

      public byte[] footerBytes()
      Specified by:
      footerBytes in interface Encoder<Event extends DeferredProcessingAware>
    • getProviders

      public JsonProviders<Event> getProviders()
    • setProviders

      public void setProviders(JsonProviders<Event> jsonProviders)
    • getJsonFactoryDecorator

      public JsonFactoryDecorator getJsonFactoryDecorator()
    • setJsonFactoryDecorator

      public void setJsonFactoryDecorator(JsonFactoryDecorator jsonFactoryDecorator)
    • getJsonGeneratorDecorator

      public JsonGeneratorDecorator getJsonGeneratorDecorator()
    • getEncoding

      public String getEncoding()
    • setEncoding

      public void setEncoding(String encodingName)
      The character encoding to use (default = "UTF-8"). Must an encoding supported by JsonEncoding
      Parameters:
      encodingName - encoding name
    • setFindAndRegisterJacksonModules

      public void setFindAndRegisterJacksonModules(boolean findAndRegisterJacksonModules)
    • setJsonGeneratorDecorator

      public void setJsonGeneratorDecorator(JsonGeneratorDecorator jsonGeneratorDecorator)
    • getLineSeparator

      public String getLineSeparator()
    • setLineSeparator

      public void setLineSeparator(String lineSeparator)
      Sets which lineSeparator to use between events.

      The following values have special meaning:

      • null or empty string = no new line.
      • "SYSTEM" = operating system new line (default).
      • "UNIX" = unix line ending (\n).
      • "WINDOWS" = windows line ending \r\n).

      Any other value will be used as given as the lineSeparator.

      Parameters:
      lineSeparator - the line separator
    • getMinBufferSize

      public int getMinBufferSize()
    • setMinBufferSize

      public void setMinBufferSize(int minBufferSize)
      The minimum size of the byte buffer used when encoding events.

      The buffer automatically grows above the #minBufferSize when needed to accommodate with larger events. However, only the first minBufferSize bytes will be reused by subsequent invocations. It is therefore strongly advised to set the minimum size at least equal to the average size of the encoded events to reduce unnecessary memory allocations and reduce pressure on the garbage collector.

      Note: changes to the buffer size will not be taken into account after the encoder is started.

      Parameters:
      minBufferSize - minimum size of the byte buffer (in bytes)
    • getFormatter

      protected AbstractCompositeJsonFormatter<Event> getFormatter()
    • getPrefix

      public Encoder<Event> getPrefix()
    • setPrefix

      public void setPrefix(Encoder<Event> prefix)
    • getSuffix

      public Encoder<Event> getSuffix()
    • setSuffix

      public void setSuffix(Encoder<Event> suffix)