public class ObjectFieldsAppendingMarker extends LogstashMarker implements StructuredArgument
Marker OR StructuredArgument that
that "unwraps" the given object into the logstash event.
When writing to the JSON data (via ArgumentsJsonProvider or LogstashMarkersJsonProvider),
the fields of the object are written inline into the JSON event
similar to how the com.fasterxml.jackson.annotation.JsonUnwrapped annotation works.
When writing to a String (when used as a StructuredArgument to the event's formatted message),
StructuredArguments.toString(Object) is used to convert the object to a string.
For example, if the message is "mymessage {}", and the object argument is:
{
name1 : "value1",
name2 : 5,
name3 : [1, 2, 3],
name4 : {
name5 : 6
}
}
Then the message, name1, name2, name3, name4 fields will be added to the json for the logstash event.
For example:
{
"message" : "mymessage objectsToStringValue",
"name1" : "value1",
"name2" : 5,
"name3" : [1, 2, 3],
"name4" : { "name5" : 6 }
}
Note that if the object cannot be unwrapped, then nothing will be written.| Modifier and Type | Field and Description |
|---|---|
static String |
MARKER_NAME |
MARKER_NAME_PREFIX| Constructor and Description |
|---|
ObjectFieldsAppendingMarker(Object object) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
int |
hashCode() |
String |
toStringSelf()
Returns a string representation of this object, without including any references.
|
void |
writeTo(com.fasterxml.jackson.core.JsonGenerator generator)
Writes the data associated with this marker to the given
JsonGenerator. |
and, toString, withadd, contains, contains, getName, hasChildren, hasReferences, iterator, removeclone, finalize, getClass, notify, notifyAll, wait, wait, waittoStringforEach, iterator, spliteratorpublic static final String MARKER_NAME
public ObjectFieldsAppendingMarker(Object object)
public void writeTo(com.fasterxml.jackson.core.JsonGenerator generator)
throws IOException
LogstashMarkerJsonGenerator.writeTo in interface StructuredArgumentwriteTo in class LogstashMarkergenerator - the generator to which to write the output of this marker.IOException - if there was an error writing to the generatorpublic String toStringSelf()
LogstashMarkerSubclasses should override LogstashMarker.toStringSelf() instead of LogstashMarker.toString(),
since LogstashMarker.toString() will automatically include the LogstashMarker.toStringSelf() and references.
toStringSelf in class LogstashMarkerpublic boolean equals(Object obj)
equals in interface org.slf4j.Markerequals in class LogstashBasicMarkerpublic int hashCode()
hashCode in interface org.slf4j.MarkerhashCode in class LogstashBasicMarkerCopyright © 2019. All rights reserved.