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 the builder factory method to create this.
  • Method Details

    • 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) and System.console() is null, do not output ANSI escape codes
    • withHeader

      public PatternLayout.Builder withHeader(String header)
      Parameters:
      header - The header 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 interface Builder<PatternLayout>
      Returns:
      the configured instance.