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 (ILoggingEvent
orIAccessEvent
).
- 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
JsonProvider
s.
The AbstractCompositeJsonFormatter
starts the JSON object ('{'),
then delegates writing the contents of the object to the JsonProvider
s,
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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
protected void
void
setEncoding
(String encodingName) void
setFindAndRegisterJacksonModules
(boolean findAndRegisterJacksonModules) void
setJsonFactoryDecorator
(JsonFactoryDecorator jsonFactoryDecorator) void
setJsonGeneratorDecorator
(JsonGeneratorDecorator jsonGeneratorDecorator) void
setProviders
(JsonProviders<Event> jsonProviders) void
start()
void
stop()
void
writeEvent
(Event event, OutputStream outputStream) Write an event in the given output stream.protected void
writeEventToGenerator
(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)
-