Class DeferredStructuredArgument
java.lang.Object
net.logstash.logback.argument.DeferredStructuredArgument
- All Implemented Interfaces:
StructuredArgument
A
StructuredArgument that defers the creation of another StructuredArgument until
the first time its value is needed.
The value is needed in the following conditions:
- When
LoggingEvent.getFormattedMessage()is called - When
LoggingEvent.prepareForDeferredProcessing()()} is called (async appenders call this prior to dispatching the event to another thread) - When the
LoggingEventis encoded
The deferred value will always be created in the thread calling the Logger
(even if an async appender is used) since the values of structured arguments are needed
when LoggingEvent.prepareForDeferredProcessing() is called
(by async appenders prior to dispatching the event to another thread).
The deferred value will only be calculated once. The single value supplied by the supplier will be reused every time the structured argument is written. For example, if multiple appenders use a logstash encoder, the supplier will be invoked when the first appender encodes the marker. That same supplied value will be used when the next appender encodes the marker.
-
Constructor Summary
ConstructorsConstructorDescriptionDeferredStructuredArgument(Supplier<? extends StructuredArgument> structureArgumentSupplier) -
Method Summary
Modifier and TypeMethodDescriptionvoidwriteTo(JsonGenerator generator) Writes the data associated with this argument to the givenJsonGenerator.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface StructuredArgument
toString
-
Constructor Details
-
DeferredStructuredArgument
-
-
Method Details
-
writeTo
Description copied from interface:StructuredArgumentWrites the data associated with this argument to the givenJsonGenerator.- Specified by:
writeToin interfaceStructuredArgument- Parameters:
generator- theJsonGeneratorto produce JSON content
-