@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.
Configure as follows to send to a Graylog2 server:
<Appenders>
<Socket name="Graylog" protocol="udp" host="graylog.domain.com" port="12201">
<GelfLayout host="someserver" compressionType="GZIP" compressionThreshold="1024">
<KeyValuePair key="additionalField1" value="additional value 1"/>
<KeyValuePair key="additionalField2" value="additional value 2"/>
</GelfLayout>
</Socket>
</Appenders>
| Modifier and Type | Class and Description |
|---|---|
static class |
GelfLayout.CompressionType |
footer, header, LOGGERELEMENT_TYPE| Constructor and Description |
|---|
GelfLayout(String host,
KeyValuePair[] additionalFields,
GelfLayout.CompressionType compressionType,
int compressionThreshold) |
| Modifier and Type | Method and Description |
|---|---|
static GelfLayout |
createLayout(String host,
KeyValuePair[] additionalFields,
GelfLayout.CompressionType compressionType,
int compressionThreshold) |
Map<String,String> |
getContentFormat()
Returns a description of the content format.
|
String |
getContentType()
Returns the content type output by this layout.
|
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, getCharsetgetFooter, getHeaderpublic GelfLayout(String host, KeyValuePair[] additionalFields, GelfLayout.CompressionType compressionType, int compressionThreshold)
@PluginFactory 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)
public Map<String,String> getContentFormat()
LayoutgetContentFormat in interface Layout<String>getContentFormat in class AbstractLayout<String>public String getContentType()
LayoutgetContentType in interface Layout<String>getContentType in class AbstractStringLayoutpublic byte[] toByteArray(LogEvent event)
AbstractStringLayouttoByteArray in interface Layout<String>toByteArray in class AbstractStringLayoutevent - The Log Event.Copyright © 1999-2021 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.