Class GelfLayout.Builder<B extends GelfLayout.Builder<B>>
java.lang.Object
org.apache.logging.log4j.core.layout.AbstractLayout.Builder<B>
org.apache.logging.log4j.core.layout.AbstractStringLayout.Builder<B>
org.apache.logging.log4j.core.layout.GelfLayout.Builder<B>
- All Implemented Interfaces:
Builder<GelfLayout>
- Enclosing class:
- GelfLayout
public static class GelfLayout.Builder<B extends GelfLayout.Builder<B>>
extends AbstractStringLayout.Builder<B>
implements Builder<GelfLayout>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the object after all configuration has been set.int
getHost()
boolean
boolean
boolean
boolean
setAdditionalFields
(KeyValuePair[] additionalFields) Additional fields to set on each log event.setCompressionThreshold
(int compressionThreshold) Compress if data is larger than this number of bytes (optional, defaults to 1024).setCompressionType
(GelfLayout.CompressionType compressionType) Compression to use (optional, defaults to GZIP).The value of thehost
property (optional, defaults to local host name).setIncludeMapMessage
(boolean includeMapMessage) Whether to include MapMessage fields as additional fields (optional, default to true).setIncludeNewLineDelimiter
(boolean includeNewLineDelimiter) Whether to include newline (LF) as delimiter after each event (optional, default to false).setIncludeNullDelimiter
(boolean includeNullDelimiter) Whether to include NULL byte as delimiter after each event (optional, default to false).setIncludeStacktrace
(boolean includeStacktrace) Whether to include full stacktrace of logged Throwables (optional, default to true).setIncludeThreadContext
(boolean includeThreadContext) Whether to include thread context as additional fields (optional, default to true).setMapMessageExcludes
(String mapMessageExcludes) A comma separated list of MapMessage keys to exclude;setMapMessageIncludes
(String mapMessageIncludes) A comma separated list of thread context keys to include;setMapPrefix
(String prefix) The String to prefix the MapMessage attributes.setMdcExcludes
(String mdcExcludes) A comma separated list of thread context keys to include;setMdcIncludes
(String mdcIncludes) A comma separated list of thread context keys to include;setMessagePattern
(String pattern) The pattern to use to format the message.setPatternSelector
(PatternSelector patternSelector) The PatternSelector to use to format the message.setThreadContextPrefix
(String prefix) The String to prefix the ThreadContext attributes.Methods inherited from class org.apache.logging.log4j.core.layout.AbstractStringLayout.Builder
getCharset, getFooterSerializer, getHeaderSerializer, setCharset, setFooterSerializer, setHeaderSerializer
Methods inherited from class org.apache.logging.log4j.core.layout.AbstractLayout.Builder
asBuilder, getConfiguration, getFooter, getHeader, setConfiguration, setFooter, setHeader
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.logging.log4j.core.util.Builder
getErrorPrefix, isValid
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
Description copied from interface:Builder
Builds the object after all configuration has been set. This will use default values for any unspecified attributes for the object.- Specified by:
build
in interfaceBuilder<B extends GelfLayout.Builder<B>>
- Returns:
- the configured instance.
-
getHost
-
getCompressionType
-
getCompressionThreshold
public int getCompressionThreshold() -
isIncludeStacktrace
public boolean isIncludeStacktrace() -
isIncludeThreadContext
public boolean isIncludeThreadContext() -
isIncludeNullDelimiter
public boolean isIncludeNullDelimiter() -
isIncludeNewLineDelimiter
public boolean isIncludeNewLineDelimiter() -
getAdditionalFields
-
setHost
The value of thehost
property (optional, defaults to local host name).- Returns:
- this builder
-
setCompressionType
Compression to use (optional, defaults to GZIP).- Returns:
- this builder
-
setCompressionThreshold
Compress if data is larger than this number of bytes (optional, defaults to 1024).- Returns:
- this builder
-
setIncludeStacktrace
Whether to include full stacktrace of logged Throwables (optional, default to true). If set to false, only the class name and message of the Throwable will be included.- Returns:
- this builder
-
setIncludeThreadContext
Whether to include thread context as additional fields (optional, default to true).- Returns:
- this builder
-
setIncludeNullDelimiter
Whether to include NULL byte as delimiter after each event (optional, default to false). Useful for Graylog GELF TCP input.- Returns:
- this builder
-
setIncludeNewLineDelimiter
Whether to include newline (LF) as delimiter after each event (optional, default to false).- Returns:
- this builder
-
setAdditionalFields
Additional fields to set on each log event.- Returns:
- this builder
-
setMessagePattern
The pattern to use to format the message.- Parameters:
pattern
- the pattern string.- Returns:
- this builder
-
setPatternSelector
The PatternSelector to use to format the message.- Parameters:
patternSelector
- the PatternSelector.- Returns:
- this builder
-
setMdcIncludes
A comma separated list of thread context keys to include;- Parameters:
mdcIncludes
- the list of keys.- Returns:
- this builder
-
setMdcExcludes
A comma separated list of thread context keys to include;- Parameters:
mdcExcludes
- the list of keys.- Returns:
- this builder
-
setIncludeMapMessage
Whether to include MapMessage fields as additional fields (optional, default to true).- Returns:
- this builder
-
setMapMessageIncludes
A comma separated list of thread context keys to include;- Parameters:
mapMessageIncludes
- the list of keys.- Returns:
- this builder
-
setMapMessageExcludes
A comma separated list of MapMessage keys to exclude;- Parameters:
mapMessageExcludes
- the list of keys.- Returns:
- this builder
-
setThreadContextPrefix
The String to prefix the ThreadContext attributes.- Parameters:
prefix
- The prefix value. Null values will be ignored.- Returns:
- this builder.
-
setMapPrefix
The String to prefix the MapMessage attributes.- Parameters:
prefix
- The prefix value. Null values will be ignored.- Returns:
- this builder.
-