public abstract class LogstashMarker extends LogstashBasicMarker implements Iterable<org.slf4j.Marker>
Marker
that is known and understood by the logstash logback encoder.
In particular these markers are used to write data into the logstash json event via writeTo(JsonGenerator)
.
Modifier and Type | Field and Description |
---|---|
static String |
MARKER_NAME_PREFIX |
Constructor and Description |
---|
LogstashMarker(String name) |
Modifier and Type | Method and Description |
---|---|
<T extends LogstashMarker> |
and(org.slf4j.Marker reference)
Adds the given marker as a reference, and returns this marker.
|
String |
toString()
Returns a String in the form of
|
protected String |
toStringSelf()
Returns a string representation of this object, without including any references.
|
<T extends LogstashMarker> |
with(org.slf4j.Marker reference)
Deprecated.
Use
and(Marker) instead |
abstract void |
writeTo(com.fasterxml.jackson.core.JsonGenerator generator)
Writes the data associated with this marker to the given
JsonGenerator . |
add, contains, contains, equals, getName, hasChildren, hashCode, hasReferences, iterator, remove
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, iterator, spliterator
public static final String MARKER_NAME_PREFIX
public LogstashMarker(String name)
public <T extends LogstashMarker> T and(org.slf4j.Marker reference)
This can be used to chain markers together fluently on a log line. For example:
import static net.logstash.logback.marker.Markers.*
logger.info(append("name1", "value1).and(append("name2", "value2")), "log message");
T
- subtype of LogstashMarkerreference
- The marker to add@Deprecated public <T extends LogstashMarker> T with(org.slf4j.Marker reference)
and(Marker)
insteadT
- subtype of LogstashMarkerreference
- The marker to addand(Marker)
public abstract void writeTo(com.fasterxml.jackson.core.JsonGenerator generator) throws IOException
JsonGenerator
.generator
- the generator to which to write the output of this marker.IOException
- if there was an error writing to the generatorpublic String toString()
self, reference1, reference2, ...
Where self
is the value returned by toStringSelf()
,
and reference*
are the toString()
values of any references.
It is recommended that subclasses only override toStringSelf()
,
so that references are automatically included in the value returned from toString()
.
toString
in class LogstashBasicMarker
protected String toStringSelf()
Subclasses should override toStringSelf()
instead of toString()
,
since toString()
will automatically include the toStringSelf()
and references.
Copyright © 2019. All rights reserved.