Class JsonWriterStructuredLogFormatter<E>
java.lang.Object
org.springframework.boot.logging.structured.JsonWriterStructuredLogFormatter<E>
- Type Parameters:
E
- the log event type
- All Implemented Interfaces:
StructuredLogFormatter<E>
public abstract class JsonWriterStructuredLogFormatter<E>
extends Object
implements StructuredLogFormatter<E>
Base class for
StructuredLogFormatter
implementations that generates JSON using
a JsonWriter
.- Since:
- 3.4.0
-
Constructor Summary
ModifierConstructorDescriptionprotected
JsonWriterStructuredLogFormatter
(Consumer<JsonWriter.Members<E>> members, StructuredLoggingJsonMembersCustomizer<?> customizer) Create a newJsonWriterStructuredLogFormatter
instance with the given members.protected
JsonWriterStructuredLogFormatter
(JsonWriter<E> jsonWriter) Create a newJsonWriterStructuredLogFormatter
instance with the givenJsonWriter
. -
Method Summary
-
Constructor Details
-
JsonWriterStructuredLogFormatter
protected JsonWriterStructuredLogFormatter(Consumer<JsonWriter.Members<E>> members, StructuredLoggingJsonMembersCustomizer<?> customizer) Create a newJsonWriterStructuredLogFormatter
instance with the given members.- Parameters:
members
- a consumer, which should configure the memberscustomizer
- an optional customizer to apply
-
JsonWriterStructuredLogFormatter
Create a newJsonWriterStructuredLogFormatter
instance with the givenJsonWriter
.- Parameters:
jsonWriter
- theJsonWriter
-
-
Method Details
-
format
Description copied from interface:StructuredLogFormatter
Formats the given log event to a String.- Specified by:
format
in interfaceStructuredLogFormatter<E>
- Parameters:
event
- the log event to write- Returns:
- the formatted log event String
-
formatAsBytes
Description copied from interface:StructuredLogFormatter
Formats the given log event to a byte array.- Specified by:
formatAsBytes
in interfaceStructuredLogFormatter<E>
- Parameters:
event
- the log event to writecharset
- the charset- Returns:
- the formatted log event bytes
-