Class JsonTemplateLayout
- java.lang.Object
-
- org.apache.logging.log4j.layout.template.json.JsonTemplateLayout
-
- All Implemented Interfaces:
Layout<String>
,Encoder<LogEvent>
,StringLayout
@Plugin(name="JsonTemplateLayout", category="Core", elementType="layout") public class JsonTemplateLayout extends Object implements StringLayout
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JsonTemplateLayout.Builder
static class
JsonTemplateLayout.EventTemplateAdditionalField
-
Field Summary
-
Fields inherited from interface org.apache.logging.log4j.core.Layout
ELEMENT_TYPE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
encode(LogEvent event, ByteBufferDestination destination)
Encodes the specified source object to some binary representation and writes the result to the specified destination.Charset
getCharset()
Gets the Charset this layout uses to encode Strings into bytes.Map<String,String>
getContentFormat()
Returns a description of the content format.String
getContentType()
Returns the content type output by this layout.byte[]
getFooter()
Returns the format for the layout format.byte[]
getHeader()
Returns the header for the layout format.static JsonTemplateLayout.Builder
newBuilder()
byte[]
toByteArray(LogEvent event)
Formats the event suitable for display.String
toSerializable(LogEvent event)
Formats the event as an Object that can be serialized.
-
-
-
Method Detail
-
toByteArray
public byte[] toByteArray(LogEvent event)
Description copied from interface:Layout
Formats the event suitable for display.- Specified by:
toByteArray
in interfaceLayout<String>
- Parameters:
event
- The Logging Event.- Returns:
- The formatted event.
-
toSerializable
public String toSerializable(LogEvent event)
Description copied from interface:Layout
Formats the event as an Object that can be serialized.- Specified by:
toSerializable
in interfaceLayout<String>
- Parameters:
event
- The Logging Event.- Returns:
- The formatted event.
-
encode
public void encode(LogEvent event, ByteBufferDestination destination)
Description copied from interface:Encoder
Encodes the specified source object to some binary representation and writes the result to the specified destination.
-
getFooter
public byte[] getFooter()
Description copied from interface:Layout
Returns the format for the layout format.
-
getHeader
public byte[] getHeader()
Description copied from interface:Layout
Returns the header for the layout format.
-
getCharset
public Charset getCharset()
Description copied from interface:StringLayout
Gets the Charset this layout uses to encode Strings into bytes.- Specified by:
getCharset
in interfaceStringLayout
- Returns:
- the Charset this layout uses to encode Strings into bytes.
-
getContentType
public String getContentType()
Description copied from interface:Layout
Returns the content type output by this layout. The base class returns "text/plain".- Specified by:
getContentType
in interfaceLayout<String>
- Returns:
- the content type.
-
getContentFormat
public Map<String,String> getContentFormat()
Description copied from interface:Layout
Returns a description of the content format.- Specified by:
getContentFormat
in interfaceLayout<String>
- Returns:
- a Map of key/value pairs describing the Layout-specific content format, or an empty Map if no content format descriptors are specified.
-
newBuilder
@PluginBuilderFactory public static JsonTemplateLayout.Builder newBuilder()
-
-