Class PatternLayout.Builder
- java.lang.Object
-
- org.apache.logging.log4j.core.layout.PatternLayout.Builder
-
- All Implemented Interfaces:
Builder<PatternLayout>
- Enclosing class:
- PatternLayout
public static class PatternLayout.Builder extends java.lang.Object implements Builder<PatternLayout>
Custom PatternLayout builder. Use thebuilder factory method
to create this.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
alwaysWriteExceptions
private java.nio.charset.Charset
charset
private Configuration
configuration
private boolean
disableAnsi
private java.lang.String
footer
private java.lang.String
header
private boolean
noConsoleNoAnsi
private java.lang.String
pattern
private PatternSelector
patternSelector
private RegexReplacement
regexReplacement
-
Constructor Summary
Constructors Modifier Constructor Description private
Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PatternLayout
build()
Builds the object after all configuration has been set.private boolean
useAnsiEscapeCodes()
PatternLayout.Builder
withAlwaysWriteExceptions(boolean alwaysWriteExceptions)
PatternLayout.Builder
withCharset(java.nio.charset.Charset charset)
PatternLayout.Builder
withConfiguration(Configuration configuration)
PatternLayout.Builder
withDisableAnsi(boolean disableAnsi)
PatternLayout.Builder
withFooter(java.lang.String footer)
PatternLayout.Builder
withHeader(java.lang.String header)
PatternLayout.Builder
withNoConsoleNoAnsi(boolean noConsoleNoAnsi)
PatternLayout.Builder
withPattern(java.lang.String pattern)
PatternLayout.Builder
withPatternSelector(PatternSelector patternSelector)
PatternLayout.Builder
withRegexReplacement(RegexReplacement regexReplacement)
-
-
-
Field Detail
-
pattern
@PluginBuilderAttribute private java.lang.String pattern
-
patternSelector
@PluginElement("PatternSelector") private PatternSelector patternSelector
-
configuration
@PluginConfiguration private Configuration configuration
-
regexReplacement
@PluginElement("Replace") private RegexReplacement regexReplacement
-
charset
@PluginBuilderAttribute private java.nio.charset.Charset charset
-
alwaysWriteExceptions
@PluginBuilderAttribute private boolean alwaysWriteExceptions
-
disableAnsi
@PluginBuilderAttribute private boolean disableAnsi
-
noConsoleNoAnsi
@PluginBuilderAttribute private boolean noConsoleNoAnsi
-
header
@PluginBuilderAttribute private java.lang.String header
-
footer
@PluginBuilderAttribute private java.lang.String footer
-
-
Method Detail
-
useAnsiEscapeCodes
private boolean useAnsiEscapeCodes()
-
withPattern
public PatternLayout.Builder withPattern(java.lang.String pattern)
- Parameters:
pattern
- The pattern. If not specified, defaults to DEFAULT_CONVERSION_PATTERN.
-
withPatternSelector
public PatternLayout.Builder withPatternSelector(PatternSelector patternSelector)
- Parameters:
patternSelector
- Allows different patterns to be used based on some selection criteria.
-
withConfiguration
public PatternLayout.Builder withConfiguration(Configuration configuration)
- Parameters:
configuration
- The Configuration. Some Converters require access to the Interpolator.
-
withRegexReplacement
public PatternLayout.Builder withRegexReplacement(RegexReplacement regexReplacement)
- Parameters:
regexReplacement
- A Regex replacement
-
withCharset
public PatternLayout.Builder withCharset(java.nio.charset.Charset charset)
- Parameters:
charset
- The character set. The platform default is used if not specified.
-
withAlwaysWriteExceptions
public PatternLayout.Builder withAlwaysWriteExceptions(boolean alwaysWriteExceptions)
- Parameters:
alwaysWriteExceptions
- If"true"
(default) exceptions are always written even if the pattern contains no exception tokens.
-
withDisableAnsi
public PatternLayout.Builder withDisableAnsi(boolean disableAnsi)
- Parameters:
disableAnsi
- If"true"
(default is value of system property `log4j.skipJansi`, or `true` if undefined), do not output ANSI escape codes
-
withNoConsoleNoAnsi
public PatternLayout.Builder withNoConsoleNoAnsi(boolean noConsoleNoAnsi)
- Parameters:
noConsoleNoAnsi
- If"true"
(default is false) andSystem.console()
is null, do not output ANSI escape codes
-
withHeader
public PatternLayout.Builder withHeader(java.lang.String header)
- Parameters:
header
- The footer to place at the top of the document, once.
-
withFooter
public PatternLayout.Builder withFooter(java.lang.String footer)
- Parameters:
footer
- The footer to place at the bottom of the document, once.
-
build
public PatternLayout 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<PatternLayout>
- Returns:
- the configured instance.
-
-