Class PatternLayout

java.lang.Object
org.apache.log4j.Layout
org.apache.log4j.PatternLayout

public class PatternLayout extends Layout
  • Field Details

    • DEFAULT_CONVERSION_PATTERN

      public static final String DEFAULT_CONVERSION_PATTERN
      Default pattern string for log output. Currently set to the string "%m%n" which just prints the application supplied message.
      See Also:
    • TTCC_CONVERSION_PATTERN

      public static final String TTCC_CONVERSION_PATTERN
      A conversion pattern equivalent to the TTCCCLayout. Current value is "%r [%t] %p %c %x - %m%n"
      See Also:
    • BUF_SIZE

      protected final int BUF_SIZE
      See Also:
    • MAX_CAPACITY

      protected final int MAX_CAPACITY
      See Also:
    • sbuf

      private StringBuffer sbuf
    • pattern

      private String pattern
  • Constructor Details

    • PatternLayout

      public PatternLayout()
      Constructs a PatternLayout using the DEFAULT_LAYOUT_PATTERN. The default pattern just produces the application supplied message.
    • PatternLayout

      public PatternLayout(String pattern)
      Constructs a PatternLayout using the supplied conversion pattern.
  • Method Details

    • activateOptions

      public void activateOptions()
      Does not do anything as options become effective
    • createPatternParser

      protected PatternParser createPatternParser(String pattern)
      Returns PatternParser used to parse the conversion string. Subclasses may override this to return a subclass of PatternParser which recognize custom conversion characters.
      Since:
      0.9.0
    • format

      public String format(LoggingEvent event)
      Produces a formatted string as specified by the conversion pattern.
      Specified by:
      format in class Layout
      Parameters:
      event - The LoggingEvent.
      Returns:
      The formatted LoggingEvent.
    • getConversionPattern

      public String getConversionPattern()
      Returns the value of the ConversionPattern option.
    • ignoresThrowable

      public boolean ignoresThrowable()
      The PatternLayout does not handle the throwable contained within LoggingEvents. Thus, it returns true.
      Specified by:
      ignoresThrowable in class Layout
      Returns:
      true if the Layout ignores Throwables.
      Since:
      0.8.4
    • setConversionPattern

      public void setConversionPattern(String conversionPattern)
      Set the ConversionPattern option. This is the string which controls formatting and consists of a mix of literal content and conversion specifiers.