Class AbstractCompositeJsonFormatter<Event extends DeferredProcessingAware>

java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
net.logstash.logback.composite.AbstractCompositeJsonFormatter<Event>
Type Parameters:
Event - type of event (ILoggingEvent or IAccessEvent).
All Implemented Interfaces:
ContextAware, LifeCycle
Direct Known Subclasses:
AccessEventCompositeJsonFormatter, CompositeJsonFormatter, LoggingEventCompositeJsonFormatter

public abstract class AbstractCompositeJsonFormatter<Event extends DeferredProcessingAware> extends ContextAwareBase implements LifeCycle
Formats logstash Events as JSON using JsonProviders.

The AbstractCompositeJsonFormatter starts the JSON object ('{'), then delegates writing the contents of the object to the JsonProviders, and then ends the JSON object ('}').

Jackson JsonGenerator are initially created with a "disconnected" output stream so they can be reused multiple times with different target output stream.

JsonGenerator instances are *not* reused after they threw an exception. This is to prevent reusing an instance whose internal state may be unpredictable.

Author:
brenuart
  • Constructor Details

    • AbstractCompositeJsonFormatter

      public AbstractCompositeJsonFormatter(ContextAware declaredOrigin)
  • Method Details

    • start

      public void start()
      Specified by:
      start in interface LifeCycle
    • stop

      public void stop()
      Specified by:
      stop in interface LifeCycle
    • isStarted

      public boolean isStarted()
      Specified by:
      isStarted in interface LifeCycle
    • writeEvent

      public void writeEvent(Event event, OutputStream outputStream) throws IOException
      Write an event in the given output stream.
      Parameters:
      event - the event to write
      outputStream - the output stream to write the event into
      Throws:
      IOException - thrown upon failure to write the event
    • writeEventToGenerator

      protected void writeEventToGenerator(JsonGenerator generator, Event event) throws IOException
      Throws:
      IOException
    • prepareForDeferredProcessing

      protected void prepareForDeferredProcessing(Event event)
    • getJsonFactory

      public JsonFactory getJsonFactory()
    • getJsonFactoryDecorator

      public JsonFactoryDecorator getJsonFactoryDecorator()
    • setJsonFactoryDecorator

      public void setJsonFactoryDecorator(JsonFactoryDecorator jsonFactoryDecorator)
    • getJsonGeneratorDecorator

      public JsonGeneratorDecorator getJsonGeneratorDecorator()
    • setJsonGeneratorDecorator

      public void setJsonGeneratorDecorator(JsonGeneratorDecorator jsonGeneratorDecorator)
    • getProviders

      public JsonProviders<Event> getProviders()
    • getEncoding

      public String getEncoding()
    • setEncoding

      public void setEncoding(String encodingName)
    • setProviders

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

      public boolean isFindAndRegisterJacksonModules()
    • setFindAndRegisterJacksonModules

      public void setFindAndRegisterJacksonModules(boolean findAndRegisterJacksonModules)