public class DeferredStructuredArgument extends Object implements StructuredArgument
StructuredArgument
that defers the creation of another StructuredArgument
until
the first time its value is needed.
The value is needed in the following conditions:
LoggingEvent.getFormattedMessage()
is calledLoggingEvent.prepareForDeferredProcessing()
()} is called
(async appenders call this prior to dispatching the event to another thread)LoggingEvent
is encodedThe 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 and Description |
---|
DeferredStructuredArgument(Supplier<? extends StructuredArgument> structureArgumentSupplier) |
Modifier and Type | Method and Description |
---|---|
void |
writeTo(JsonGenerator generator)
Writes the data associated with this argument to the given
JsonGenerator . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toString
public DeferredStructuredArgument(Supplier<? extends StructuredArgument> structureArgumentSupplier)
public void writeTo(JsonGenerator generator) throws IOException
StructuredArgument
JsonGenerator
.writeTo
in interface StructuredArgument
generator
- the JsonGenerator
to produce JSON contentIOException
- if an I/O error occursCopyright © 2013–2022. All rights reserved.