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 Object implements Builder<PatternLayout>
Custom PatternLayout builder. Use thebuilder factory method
to create this.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PatternLayout
build()
Builds the object after all configuration has been set.PatternLayout.Builder
withAlwaysWriteExceptions(boolean alwaysWriteExceptions)
PatternLayout.Builder
withCharset(Charset charset)
PatternLayout.Builder
withConfiguration(Configuration configuration)
PatternLayout.Builder
withDisableAnsi(boolean disableAnsi)
PatternLayout.Builder
withFooter(String footer)
PatternLayout.Builder
withHeader(String header)
PatternLayout.Builder
withNoConsoleNoAnsi(boolean noConsoleNoAnsi)
PatternLayout.Builder
withPattern(String pattern)
PatternLayout.Builder
withPatternSelector(PatternSelector patternSelector)
PatternLayout.Builder
withRegexReplacement(RegexReplacement regexReplacement)
-
-
-
Method Detail
-
withPattern
public PatternLayout.Builder withPattern(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(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(String header)
- Parameters:
header
- The footer to place at the top of the document, once.
-
withFooter
public PatternLayout.Builder withFooter(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.
-
-