Package net.logstash.logback.composite
Class AbstractPatternJsonProvider<Event extends DeferredProcessingAware>
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
net.logstash.logback.composite.AbstractJsonProvider<Event>
net.logstash.logback.composite.AbstractPatternJsonProvider<Event>
- Type Parameters:
Event
- type of event (ILoggingEvent
orIAccessEvent
).
- All Implemented Interfaces:
ContextAware
,JsonFactoryAware
,JsonProvider<Event>
- Direct Known Subclasses:
AccessEventPatternJsonProvider
,LoggingEventPatternJsonProvider
public abstract class AbstractPatternJsonProvider<Event extends DeferredProcessingAware>
extends AbstractJsonProvider<Event>
implements JsonFactoryAware
Transforms an string containing patterns understood by PatternLayouts into JSON output.
Delegates most of the work to the
AbstractJsonPatternParser
that is to
parse the pattern specified.
Subclasses must implement createParser(JsonFactory)
method so it returns parser valid for a specified event class.- Author:
- Dmitry Andrianov
-
Field Summary
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AbstractJsonPatternParser<Event>
createParser
(JsonFactory jsonFactory) boolean
Whentrue
, fields whose values are considered empty will be omitted from JSON output.void
setJsonFactory
(JsonFactory jsonFactory) void
setOmitEmptyFields
(boolean omitEmptyFields) Whentrue
, fields whose values are considered empty will be omitted from JSON output.void
setPattern
(String pattern) void
start()
Start the provider after all configuration properties are set.void
writeTo
(JsonGenerator generator, Event event) Writes information about the event, to the given generator.Methods inherited from class net.logstash.logback.composite.AbstractJsonProvider
assertIsStarted, isStarted, prepareForDeferredProcessing, 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
-
Constructor Details
-
AbstractPatternJsonProvider
public AbstractPatternJsonProvider()
-
-
Method Details
-
writeTo
Description copied from interface:JsonProvider
Writes information about the event, to the given generator.When called, the generator is assumed to be within a JSON object context (i.e. this provider should write fields and their values to the generator). Upon return, the generator should be within the same JSON object context.
- Specified by:
writeTo
in interfaceJsonProvider<Event extends DeferredProcessingAware>
- Parameters:
generator
- theJsonGenerator
to produce JSON contentevent
- the event to convert into JSON- Throws:
IOException
- if an I/O error occurs
-
createParser
-
getPattern
-
setPattern
-
setJsonFactory
- Specified by:
setJsonFactory
in interfaceJsonFactoryAware
-
start
public void start()Description copied from interface:JsonProvider
Start the provider after all configuration properties are set.- Specified by:
start
in interfaceJsonProvider<Event extends DeferredProcessingAware>
- Overrides:
start
in classAbstractJsonProvider<Event extends DeferredProcessingAware>
-
isOmitEmptyFields
public boolean isOmitEmptyFields()Whentrue
, fields whose values are considered empty will be omitted from JSON output.- Returns:
true
if empty fields are omitted from JSON output,false
otherwise.
-
setOmitEmptyFields
public void setOmitEmptyFields(boolean omitEmptyFields) Whentrue
, fields whose values are considered empty will be omitted from JSON output.- Parameters:
omitEmptyFields
- whether empty fields are omitted or not
-