Class RecordingAppender

java.lang.Object
io.camunda.zeebe.util.logging.RecordingAppender
All Implemented Interfaces:
org.apache.logging.log4j.core.Appender, org.apache.logging.log4j.core.LifeCycle

public final class RecordingAppender extends Object implements org.apache.logging.log4j.core.Appender
An Appender decorator which delegates all method to the underlying appender while recording all events it receives through append(LogEvent). These are accessible afterwards through getAppendedEvents(), in the order in which they were appended. The default underlying appender is a NullAppender.

Note, that the RecordingAppender when used to record the log events of a logger, that the appender can only record logs starting at the enabled log level.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle

    org.apache.logging.log4j.core.LifeCycle.State
  • Field Summary

    Fields inherited from interface org.apache.logging.log4j.core.Appender

    ELEMENT_TYPE, EMPTY_ARRAY
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a RecordingAppender using a NullAppender as underlying appender.
    RecordingAppender(org.apache.logging.log4j.core.Appender delegate)
    Construct a RecordingAppender.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    append(org.apache.logging.log4j.core.LogEvent event)
     
    List<org.apache.logging.log4j.core.LogEvent>
     
    org.apache.logging.log4j.core.ErrorHandler
     
    org.apache.logging.log4j.core.Layout<? extends Serializable>
     
     
    org.apache.logging.log4j.core.LifeCycle.State
     
    boolean
     
    void
     
    boolean
     
    boolean
     
    void
    setHandler(org.apache.logging.log4j.core.ErrorHandler handler)
     
    void
     
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RecordingAppender

      public RecordingAppender(org.apache.logging.log4j.core.Appender delegate)
      Construct a RecordingAppender.
      Parameters:
      delegate - The underlying appender to delegate all log events to
    • RecordingAppender

      public RecordingAppender()
      Construct a RecordingAppender using a NullAppender as underlying appender.
  • Method Details

    • append

      public void append(org.apache.logging.log4j.core.LogEvent event)
      Specified by:
      append in interface org.apache.logging.log4j.core.Appender
    • getName

      public String getName()
      Specified by:
      getName in interface org.apache.logging.log4j.core.Appender
    • getLayout

      public org.apache.logging.log4j.core.Layout<? extends Serializable> getLayout()
      Specified by:
      getLayout in interface org.apache.logging.log4j.core.Appender
    • ignoreExceptions

      public boolean ignoreExceptions()
      Specified by:
      ignoreExceptions in interface org.apache.logging.log4j.core.Appender
    • getHandler

      public org.apache.logging.log4j.core.ErrorHandler getHandler()
      Specified by:
      getHandler in interface org.apache.logging.log4j.core.Appender
    • setHandler

      public void setHandler(org.apache.logging.log4j.core.ErrorHandler handler)
      Specified by:
      setHandler in interface org.apache.logging.log4j.core.Appender
    • getAppendedEvents

      public List<org.apache.logging.log4j.core.LogEvent> getAppendedEvents()
    • getState

      public org.apache.logging.log4j.core.LifeCycle.State getState()
      Specified by:
      getState in interface org.apache.logging.log4j.core.LifeCycle
    • initialize

      public void initialize()
      Specified by:
      initialize in interface org.apache.logging.log4j.core.LifeCycle
    • start

      public void start()
      Specified by:
      start in interface org.apache.logging.log4j.core.LifeCycle
    • stop

      public void stop()
      Specified by:
      stop in interface org.apache.logging.log4j.core.LifeCycle
    • isStarted

      public boolean isStarted()
      Specified by:
      isStarted in interface org.apache.logging.log4j.core.LifeCycle
    • isStopped

      public boolean isStopped()
      Specified by:
      isStopped in interface org.apache.logging.log4j.core.LifeCycle