Class AbstractSequenceJsonProvider<Event extends DeferredProcessingAware>
- All Implemented Interfaces:
ContextAware
,JsonProvider<Event>
- Direct Known Subclasses:
SequenceJsonProvider
,SequenceJsonProvider
With Logback 1.3 the sequence number is obtained from ILoggingEvent.getSequenceNumber()
provided the
LoggerContext is configured with a SequenceNumberGenerator
(which is not by default).
If no SequenceNumberGenerator is configured, the provider issues a warning and reverts to a locally generated
incrementing number.
With Logback versions prior to 1.3 the sequence number is generated locally by the provider itself.
If needed, a different strategy can be used by setting a custom provider with setSequenceProvider(Function)
.
-
Field Summary
FieldsFields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet a function used to access the sequenceNumber field of the supplied event.Create a default sequence provider depending on the current Logback version.Get the sequence provider used to get the sequence number associated with the supplied event.void
setSequenceProvider
(Function<Event, Long> sequenceProvider) Assign a custom sequence provider instead of relying on the default.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.AbstractFieldJsonProvider
getFieldName, setFieldName
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
-
Field Details
-
FIELD_SEQUENCE
Default JSON field name- See Also:
-
-
Constructor Details
-
AbstractSequenceJsonProvider
public AbstractSequenceJsonProvider()
-
-
Method Details
-
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>
-
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.
- Parameters:
generator
- theJsonGenerator
to produce JSON contentevent
- the event to convert into JSON- Throws:
IOException
- if an I/O error occurs
-
setSequenceProvider
Assign a custom sequence provider instead of relying on the default.- Parameters:
sequenceProvider
- the sequence provider to use to retrieve the sequence number for the event
-
getSequenceProvider
Get the sequence provider used to get the sequence number associated with the supplied event.- Returns:
- a sequence provider
-
createSequenceProvider
Create a default sequence provider depending on the current Logback version.With Logback 1.3 the sequence number is obtained for
ILoggingEvent.getSequenceNumber()
provided the LoggerContext is configured with aSequenceNumberGenerator
(which is not by default). If no SequenceNumberGenerator is configured, the provider issues a warning and reverts to a locally generated incrementing number.With Logback versions prior to 1.3 the sequence number is generated locally by the provider itself.
- Returns:
- a sequence provider
-
createNativeSequenceNumberFieldAccessor
Get a function used to access the sequenceNumber field of the supplied event.- Returns:
- a function used to access the sequenceNumber field of the supplied event.
-