@Plugin(name="GelfLayout", category="Core", elementType="layout", printObject=true) public final class GelfLayout extends AbstractStringLayout
This layout compresses JSON to GZIP or ZLIB (the compressionType
) if
log event data is larger than 1024 bytes (the compressionThreshold
).
This layout does not implement chunking.
Modifier and Type | Class and Description |
---|---|
static class |
GelfLayout.Builder<B extends GelfLayout.Builder<B>> |
static class |
GelfLayout.CompressionType |
AbstractStringLayout.Serializer, AbstractStringLayout.Serializer2
DEFAULT_STRING_BUILDER_SIZE, MAX_STRING_BUILDER_SIZE
configuration, eventCount, footer, header, LOGGER
ELEMENT_TYPE
Constructor and Description |
---|
GelfLayout(String host,
KeyValuePair[] additionalFields,
GelfLayout.CompressionType compressionType,
int compressionThreshold,
boolean includeStacktrace)
Deprecated.
Use
newBuilder() instead |
Modifier and Type | Method and Description |
---|---|
static GelfLayout |
createLayout(String host,
KeyValuePair[] additionalFields,
GelfLayout.CompressionType compressionType,
int compressionThreshold,
boolean includeStacktrace)
Deprecated.
Use
newBuilder() instead |
void |
encode(LogEvent event,
ByteBufferDestination destination)
Encodes the specified source LogEvent to some binary representation and writes the result to the specified
destination.
|
Map<String,String> |
getContentFormat()
Returns a description of the content format.
|
String |
getContentType()
Returns the content type output by this layout.
|
static <B extends GelfLayout.Builder<B>> |
newBuilder() |
byte[] |
toByteArray(LogEvent event)
Formats the Log Event as a byte array.
|
String |
toSerializable(LogEvent event)
Formats the event as an Object that can be serialized.
|
getBytes, getCharset, getFooter, getFooterSerializer, getHeader, getHeaderSerializer, getStringBuilder, getStringBuilderEncoder, requiresLocation, serializeToBytes, serializeToString, trimToMaxSize
getConfiguration, markEvent
@Deprecated public GelfLayout(String host, KeyValuePair[] additionalFields, GelfLayout.CompressionType compressionType, int compressionThreshold, boolean includeStacktrace)
newBuilder()
instead@Deprecated public static GelfLayout createLayout(@PluginAttribute(value="host") String host, @PluginElement(value="AdditionalField") KeyValuePair[] additionalFields, @PluginAttribute(value="compressionType",defaultString="GZIP") GelfLayout.CompressionType compressionType, @PluginAttribute(value="compressionThreshold",defaultInt=1024) int compressionThreshold, @PluginAttribute(value="includeStacktrace",defaultBoolean=true) boolean includeStacktrace)
newBuilder()
instead@PluginBuilderFactory public static <B extends GelfLayout.Builder<B>> B newBuilder()
public Map<String,String> getContentFormat()
Layout
getContentFormat
in interface Layout<String>
getContentFormat
in class AbstractLayout<String>
public String getContentType()
Layout
getContentType
in interface Layout<String>
getContentType
in class AbstractStringLayout
public byte[] toByteArray(LogEvent event)
AbstractStringLayout
toByteArray
in interface Layout<String>
toByteArray
in class AbstractStringLayout
event
- The Log Event.public void encode(LogEvent event, ByteBufferDestination destination)
AbstractLayout
The default implementation of this method delegates to the Layout.toByteArray(LogEvent)
method which allocates
temporary objects.
Subclasses can override this method to provide a garbage-free implementation. For text-based layouts,
AbstractStringLayout
provides various convenience methods to help with this:
@Plugin(name = "MyLayout", category = Node.CATEGORY, elementType = Layout.ELEMENT_TYPE, printObject = true) public final class MyLayout extends AbstractStringLayout {
encode
in interface Encoder<LogEvent>
encode
in class AbstractLayout<String>
event
- the LogEvent to encode.destination
- holds the ByteBuffer to write into.AbstractStringLayout.getStringBuilder()
,
AbstractStringLayout.getStringBuilderEncoder()
public String toSerializable(LogEvent event)
Layout
event
- The Logging Event.Copyright © 1999-2021 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.