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>
-
-
Field Summary
Fields Modifier and Type Field Description private KeyValuePair[]additionalFieldsprivate intcompressionThresholdprivate GelfLayout.CompressionTypecompressionTypeprivate java.lang.Stringhostprivate booleanincludeMapMessageprivate booleanincludeNewLineDelimiterprivate booleanincludeNullDelimiterprivate booleanincludeStacktraceprivate booleanincludeThreadContextprivate java.lang.StringmapMessageExcludesprivate java.lang.StringmapMessageIncludesprivate java.lang.StringmapPrefixprivate java.lang.StringmessagePatternprivate booleanomitEmptyFieldsprivate PatternSelectorpatternSelectorprivate java.lang.StringthreadContextExcludesprivate java.lang.StringthreadContextIncludesprivate java.lang.StringthreadContextPrefix
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GelfLayoutbuild()Builds the object after all configuration has been set.private ListCheckercreateChecker(java.lang.String excludes, java.lang.String includes)KeyValuePair[]getAdditionalFields()intgetCompressionThreshold()GelfLayout.CompressionTypegetCompressionType()java.lang.StringgetHost()booleanisIncludeNewLineDelimiter()booleanisIncludeNullDelimiter()booleanisIncludeStacktrace()booleanisIncludeThreadContext()BsetAdditionalFields(KeyValuePair[] additionalFields)Additional fields to set on each log event.BsetCompressionThreshold(int compressionThreshold)Compress if data is larger than this number of bytes (optional, defaults to 1024).BsetCompressionType(GelfLayout.CompressionType compressionType)Compression to use (optional, defaults to GZIP).BsetHost(java.lang.String host)The value of thehostproperty (optional, defaults to local host name).BsetIncludeMapMessage(boolean includeMapMessage)Whether to include MapMessage fields as additional fields (optional, default to true).BsetIncludeNewLineDelimiter(boolean includeNewLineDelimiter)Whether to include newline (LF) as delimiter after each event (optional, default to false).BsetIncludeNullDelimiter(boolean includeNullDelimiter)Whether to include NULL byte as delimiter after each event (optional, default to false).BsetIncludeStacktrace(boolean includeStacktrace)Whether to include full stacktrace of logged Throwables (optional, default to true).BsetIncludeThreadContext(boolean includeThreadContext)Whether to include thread context as additional fields (optional, default to true).BsetMapMessageExcludes(java.lang.String mapMessageExcludes)A comma separated list of MapMessage keys to exclude;BsetMapMessageIncludes(java.lang.String mapMessageIncludes)A comma separated list of thread context keys to include;BsetMapPrefix(java.lang.String prefix)The String to prefix the MapMessage attributes.BsetMdcExcludes(java.lang.String mdcExcludes)A comma separated list of thread context keys to include;BsetMdcIncludes(java.lang.String mdcIncludes)A comma separated list of thread context keys to include;BsetMessagePattern(java.lang.String pattern)The pattern to use to format the message.BsetPatternSelector(PatternSelector patternSelector)The PatternSelector to use to format the message.BsetThreadContextPrefix(java.lang.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
-
-
-
-
Field Detail
-
host
@PluginBuilderAttribute private java.lang.String host
-
additionalFields
@PluginElement("AdditionalField") private KeyValuePair[] additionalFields
-
compressionType
@PluginBuilderAttribute private GelfLayout.CompressionType compressionType
-
compressionThreshold
@PluginBuilderAttribute private int compressionThreshold
-
includeStacktrace
@PluginBuilderAttribute private boolean includeStacktrace
-
includeThreadContext
@PluginBuilderAttribute private boolean includeThreadContext
-
includeNullDelimiter
@PluginBuilderAttribute private boolean includeNullDelimiter
-
includeNewLineDelimiter
@PluginBuilderAttribute private boolean includeNewLineDelimiter
-
threadContextIncludes
@PluginBuilderAttribute private java.lang.String threadContextIncludes
-
threadContextExcludes
@PluginBuilderAttribute private java.lang.String threadContextExcludes
-
mapMessageIncludes
@PluginBuilderAttribute private java.lang.String mapMessageIncludes
-
mapMessageExcludes
@PluginBuilderAttribute private java.lang.String mapMessageExcludes
-
includeMapMessage
@PluginBuilderAttribute private boolean includeMapMessage
-
omitEmptyFields
@PluginBuilderAttribute private boolean omitEmptyFields
-
messagePattern
@PluginBuilderAttribute private java.lang.String messagePattern
-
threadContextPrefix
@PluginBuilderAttribute private java.lang.String threadContextPrefix
-
mapPrefix
@PluginBuilderAttribute private java.lang.String mapPrefix
-
patternSelector
@PluginElement("PatternSelector") private PatternSelector patternSelector
-
-
Method Detail
-
build
public GelfLayout build()
Description copied from interface:BuilderBuilds the object after all configuration has been set. This will use default values for any unspecified attributes for the object.- Specified by:
buildin interfaceBuilder<B extends GelfLayout.Builder<B>>- Returns:
- the configured instance.
-
createChecker
private ListChecker createChecker(java.lang.String excludes, java.lang.String includes)
-
getHost
public java.lang.String getHost()
-
getCompressionType
public GelfLayout.CompressionType getCompressionType()
-
getCompressionThreshold
public int getCompressionThreshold()
-
isIncludeStacktrace
public boolean isIncludeStacktrace()
-
isIncludeThreadContext
public boolean isIncludeThreadContext()
-
isIncludeNullDelimiter
public boolean isIncludeNullDelimiter()
-
isIncludeNewLineDelimiter
public boolean isIncludeNewLineDelimiter()
-
getAdditionalFields
public KeyValuePair[] getAdditionalFields()
-
setHost
public B setHost(java.lang.String host)
The value of thehostproperty (optional, defaults to local host name).- Returns:
- this builder
-
setCompressionType
public B setCompressionType(GelfLayout.CompressionType compressionType)
Compression to use (optional, defaults to GZIP).- Returns:
- this builder
-
setCompressionThreshold
public B setCompressionThreshold(int compressionThreshold)
Compress if data is larger than this number of bytes (optional, defaults to 1024).- Returns:
- this builder
-
setIncludeStacktrace
public B setIncludeStacktrace(boolean includeStacktrace)
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
public B setIncludeThreadContext(boolean includeThreadContext)
Whether to include thread context as additional fields (optional, default to true).- Returns:
- this builder
-
setIncludeNullDelimiter
public B setIncludeNullDelimiter(boolean includeNullDelimiter)
Whether to include NULL byte as delimiter after each event (optional, default to false). Useful for Graylog GELF TCP input.- Returns:
- this builder
-
setIncludeNewLineDelimiter
public B setIncludeNewLineDelimiter(boolean includeNewLineDelimiter)
Whether to include newline (LF) as delimiter after each event (optional, default to false).- Returns:
- this builder
-
setAdditionalFields
public B setAdditionalFields(KeyValuePair[] additionalFields)
Additional fields to set on each log event.- Returns:
- this builder
-
setMessagePattern
public B setMessagePattern(java.lang.String pattern)
The pattern to use to format the message.- Parameters:
pattern- the pattern string.- Returns:
- this builder
-
setPatternSelector
public B setPatternSelector(PatternSelector patternSelector)
The PatternSelector to use to format the message.- Parameters:
patternSelector- the PatternSelector.- Returns:
- this builder
-
setMdcIncludes
public B setMdcIncludes(java.lang.String mdcIncludes)
A comma separated list of thread context keys to include;- Parameters:
mdcIncludes- the list of keys.- Returns:
- this builder
-
setMdcExcludes
public B setMdcExcludes(java.lang.String mdcExcludes)
A comma separated list of thread context keys to include;- Parameters:
mdcExcludes- the list of keys.- Returns:
- this builder
-
setIncludeMapMessage
public B setIncludeMapMessage(boolean includeMapMessage)
Whether to include MapMessage fields as additional fields (optional, default to true).- Returns:
- this builder
-
setMapMessageIncludes
public B setMapMessageIncludes(java.lang.String mapMessageIncludes)
A comma separated list of thread context keys to include;- Parameters:
mapMessageIncludes- the list of keys.- Returns:
- this builder
-
setMapMessageExcludes
public B setMapMessageExcludes(java.lang.String mapMessageExcludes)
A comma separated list of MapMessage keys to exclude;- Parameters:
mapMessageExcludes- the list of keys.- Returns:
- this builder
-
setThreadContextPrefix
public B setThreadContextPrefix(java.lang.String prefix)
The String to prefix the ThreadContext attributes.- Parameters:
prefix- The prefix value. Null values will be ignored.- Returns:
- this builder.
-
setMapPrefix
public B setMapPrefix(java.lang.String prefix)
The String to prefix the MapMessage attributes.- Parameters:
prefix- The prefix value. Null values will be ignored.- Returns:
- this builder.
-
-