public class ObjectFieldsAppendingMarker extends LogstashMarker
JsonNode
, and then
appends the fields of the JsonNode
into the logstash event.
Unless the object is already a JsonNode), this may not be very efficient, so prefer using one of the other {@link LogstashMarker}s. It is included here for convenience where performance is not a concern.
The object will be converted to a {@link JsonNode} via {@link ObjectMapper#convertValue(Object, Class)};
For example, if the converted JsonNode is
{@code { name1 : "value1", name2 : 5, name3 : [1, 2, 3], name4 : { name5 : 6 } }
Then the name1, name2, name3, name4 fields will be added to the json for the logstash event.
For example:
{@code {
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MARKER_NAME |
MARKER_NAME_PREFIX
Constructor and Description |
---|
ObjectFieldsAppendingMarker(java.lang.Object object) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
void |
writeTo(com.fasterxml.jackson.core.JsonGenerator generator,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Writes the data associated with this marker to the given
JsonGenerator . |
with
public static final java.lang.String MARKER_NAME
public ObjectFieldsAppendingMarker(java.lang.Object object)
public void writeTo(com.fasterxml.jackson.core.JsonGenerator generator, com.fasterxml.jackson.databind.ObjectMapper mapper) throws java.io.IOException
LogstashMarker
JsonGenerator
.
The ObjectMapper
can be used to write objects if necessary. In particular ObjectMapper.writeValue(JsonGenerator, Object)
,
ObjectMapper.writeTree(JsonGenerator, com.fasterxml.jackson.databind.JsonNode)
, and ObjectMapper.writeTree(JsonGenerator, com.fasterxml.jackson.core.TreeNode)
can be useful.
writeTo
in class LogstashMarker
java.io.IOException
public boolean equals(java.lang.Object obj)
equals
in interface org.slf4j.Marker
equals
in class org.slf4j.helpers.BasicMarker
public int hashCode()
hashCode
in interface org.slf4j.Marker
hashCode
in class org.slf4j.helpers.BasicMarker
Copyright © 2014. All Rights Reserved.