Class InMemoryAppender

java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
org.kiwiproject.beta.test.logback.InMemoryAppender
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

@Beta public class InMemoryAppender extends ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
A logback appender that stores logging events in an in-memory map.

This is for testing purposes only, and is not at all intended for production use!

  • Field Summary

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

    name, started

    Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

    context
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    append(ch.qos.logback.classic.spi.ILoggingEvent eventObject)
    void
    Clear all the events that are stored in-memory.
    Map<Integer,ch.qos.logback.classic.spi.ILoggingEvent>
    Return a copy of the internal event map.
    Return the logged messages.
    List<ch.qos.logback.classic.spi.ILoggingEvent>
    Return the logged ILoggingEvent instances.
    Stream<ch.qos.logback.classic.spi.ILoggingEvent>
    Return a stream containing the logged events.

    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 Details

    • InMemoryAppender

      public InMemoryAppender()
  • Method Details

    • append

      protected void append(ch.qos.logback.classic.spi.ILoggingEvent eventObject)
      Specified by:
      append in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
    • clearEvents

      public void clearEvents()
      Clear all the events that are stored in-memory.
    • getEventMap

      public Map<Integer,ch.qos.logback.classic.spi.ILoggingEvent> getEventMap()
      Return a copy of the internal event map. The keys are the message order starting at one, and the values are the corresponding logging events.
      Returns:
      an unmodifiable copy of the event map
    • getOrderedEvents

      public List<ch.qos.logback.classic.spi.ILoggingEvent> getOrderedEvents()
      Return the logged ILoggingEvent instances.
      Returns:
      a list containing the logged events
    • getOrderedEventMessages

      public List<String> getOrderedEventMessages()
      Return the logged messages.
      Returns:
      a list containing the logged event messages
    • getOrderedEventStream

      public Stream<ch.qos.logback.classic.spi.ILoggingEvent> getOrderedEventStream()
      Return a stream containing the logged events.
      Returns:
      a stream of the logged events