Package net.logstash.logback.composite
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 (ILoggingEventorIAccessEvent).
- 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
-
Field Summary
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanprotected voidvoidsetEncoding(String encodingName) voidsetFindAndRegisterJacksonModules(boolean findAndRegisterJacksonModules) voidsetJsonFactoryDecorator(JsonFactoryDecorator jsonFactoryDecorator) voidsetJsonGeneratorDecorator(JsonGeneratorDecorator jsonGeneratorDecorator) voidsetProviders(JsonProviders<Event> jsonProviders) voidstart()voidstop()voidwriteEvent(Event event, OutputStream outputStream) Write an event in the given output stream.protected voidwriteEventToGenerator(JsonGenerator generator, Event event) Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
Constructor Details
-
AbstractCompositeJsonFormatter
-
-
Method Details
-
start
public void start() -
stop
public void stop() -
isStarted
public boolean isStarted() -
writeEvent
Write an event in the given output stream.- Parameters:
event- the event to writeoutputStream- the output stream to write the event into- Throws:
IOException- thrown upon failure to write the event
-
writeEventToGenerator
- Throws:
IOException
-
prepareForDeferredProcessing
-
getJsonFactory
-
getJsonFactoryDecorator
-
setJsonFactoryDecorator
-
getJsonGeneratorDecorator
-
setJsonGeneratorDecorator
-
getProviders
-
getEncoding
-
setEncoding
-
setProviders
-
isFindAndRegisterJacksonModules
public boolean isFindAndRegisterJacksonModules() -
setFindAndRegisterJacksonModules
public void setFindAndRegisterJacksonModules(boolean findAndRegisterJacksonModules)
-