Class CapturingAppender

  • All Implemented Interfaces:
    ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>, ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.FilterAttachable<ch.qos.logback.classic.spi.ILoggingEvent>, ch.qos.logback.core.spi.LifeCycle

    public class CapturingAppender
    extends ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
    INTERNAL API

    Logging from tests can be silenced by this appender. When there is a test failure the captured logging events are flushed to the appenders defined for the akka.actor.testkit.typed.internal.CapturingAppenderDelegate logger.

    The flushing on test failure is handled by LogCapturing for ScalaTest and LogCapturing for JUnit.

    Use configuration like the following the logback-test.xml:

    
         <appender name="CapturingAppender" class="akka.actor.testkit.typed.internal.CapturingAppender" />
    
         <logger name="akka.actor.testkit.typed.internal.CapturingAppenderDelegate" >
           <appender-ref ref="STDOUT"/>
         </logger>
    
         <root level="DEBUG">
             <appender-ref ref="CapturingAppender"/>
         </root>
     
    • Field Summary

      • Fields inherited from class ch.qos.logback.core.AppenderBase

        name, started
      • Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

        context
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void append​(ch.qos.logback.classic.spi.ILoggingEvent event)  
      void clear()
      Discards the buffered logging events without output.
      void flush()
      Flush buffered logging events to the output appenders Also clears the buffer..
      static CapturingAppender get​(java.lang.String loggerName)  
      • Methods inherited from class ch.qos.logback.core.AppenderBase

        addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, start, stop, toString
      • Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase

        addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface ch.qos.logback.core.spi.ContextAware

        addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
    • Constructor Detail

      • CapturingAppender

        public CapturingAppender()
    • Method Detail

      • append

        public void append​(ch.qos.logback.classic.spi.ILoggingEvent event)
        Specified by:
        append in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
      • flush

        public void flush()
        Flush buffered logging events to the output appenders Also clears the buffer..
      • clear

        public void clear()
        Discards the buffered logging events without output.