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
- Author:
- Phillip Webb
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJsonWriterStructuredLogFormatter(Consumer<JsonWriter.Members<E>> members, StructuredLoggingJsonMembersCustomizer<?> customizer) Create a newJsonWriterStructuredLogFormatterinstance with the given members.protectedJsonWriterStructuredLogFormatter(JsonWriter<E> jsonWriter) Create a newJsonWriterStructuredLogFormatterinstance with the givenJsonWriter. -
Method Summary
-
Constructor Details
-
JsonWriterStructuredLogFormatter
protected JsonWriterStructuredLogFormatter(Consumer<JsonWriter.Members<E>> members, StructuredLoggingJsonMembersCustomizer<?> customizer) Create a newJsonWriterStructuredLogFormatterinstance with the given members.- Parameters:
members- a consumer, which should configure the memberscustomizer- an optional customizer to apply
-
JsonWriterStructuredLogFormatter
Create a newJsonWriterStructuredLogFormatterinstance with the givenJsonWriter.- Parameters:
jsonWriter- theJsonWriter
-
-
Method Details
-
format
Description copied from interface:StructuredLogFormatterFormats the given log event to a String.- Specified by:
formatin interfaceStructuredLogFormatter<E>- Parameters:
event- the log event to write- Returns:
- the formatted log event String
-
formatAsBytes
Description copied from interface:StructuredLogFormatterFormats the given log event to a byte array.- Specified by:
formatAsBytesin interfaceStructuredLogFormatter<E>- Parameters:
event- the log event to writecharset- the charset- Returns:
- the formatted log event bytes
-