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.
If needed, a different strategy can be used by setting a custom provider with setSequenceProvider(Function).
-
Field Summary
FieldsFields inherited from class 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.voidsetSequenceProvider(Function<Event, Long> sequenceProvider) Assign a custom sequence provider instead of relying on the default.voidstart()Start the provider after all configuration properties are set.voidwriteTo(JsonGenerator generator, Event event) Writes information about the event, to the given generator.Methods inherited from class AbstractFieldJsonProvider
getFieldName, setFieldNameMethods inherited from class AbstractJsonProvider
assertIsStarted, isStarted, prepareForDeferredProcessing, stopMethods inherited from class ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Field Details
-
FIELD_SEQUENCE
-
-
Constructor Details
-
AbstractSequenceJsonProvider
public AbstractSequenceJsonProvider()
-
-
Method Details
-
start
public void start()Description copied from interface:JsonProviderStart the provider after all configuration properties are set.- Specified by:
startin interfaceJsonProvider<Event extends DeferredProcessingAware>- Overrides:
startin classAbstractJsonProvider<Event extends DeferredProcessingAware>
-
writeTo
Description copied from interface:JsonProviderWrites 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- theJsonGeneratorto produce JSON contentevent- the event to convert into JSON
-
setSequenceProvider
-
getSequenceProvider
-
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.- Returns:
- a sequence provider
-
createNativeSequenceNumberFieldAccessor
-