Class PatternLayoutAdapter<E>

java.lang.Object
net.logstash.logback.pattern.PatternLayoutAdapter<E>

public class PatternLayoutAdapter<E> extends Object
Adapter around a PatternLayoutBase to allow writing the pattern into a supplied StringBuilder instead of returning a String. The adapter also throws an IllegalArgumentException upon start when the configured pattern is not a valid pattern layout instead of simply emitting an ERROR status.
Author:
brenuart
  • Constructor Details

  • Method Details

    • setContext

      public void setContext(Context context)
      Set the Context
      Parameters:
      context - the context
    • setPattern

      public void setPattern(String pattern)
      Set the layout pattern
      Parameters:
      pattern - the layout pattern
    • start

      public void start() throws IllegalArgumentException
      Start the underlying PatternLayoutBase and throw an IllegalArgumentException if the configured pattern is not a valid PatternLayout.
      Throws:
      IllegalArgumentException - thrown when the configured pattern is not a valid PatternLayout
    • writeTo

      public void writeTo(StringBuilder strBuilder, E event)
      Apply the PatternLayout to the event and write result into the supplied StringBuilder.
      Parameters:
      strBuilder - the StringBuilder to write the result of applying the PatternLayout on the event
      event - the event to apply the pattern to
    • isConstant

      public boolean isConstant()
      Indicate whether the PatternLayoutBase always generates the same constant value regardless of the event it is given.
      Returns:
      true if the pattern is constant
    • getConstantValue

      public String getConstantValue()
      Get the constant value of the pattern or throw an IllegalStateException if the pattern is not constant.
      Returns:
      the constant value of the pattern
      See Also: