Class TestAppender

  • All Implemented Interfaces:
    org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

    public class TestAppender
    extends org.apache.log4j.WriterAppender
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.log4j.AppenderSkeleton

        org.apache.log4j.AppenderSkeleton.NoOpErrorHandler
    • Field Summary

      • Fields inherited from class org.apache.log4j.WriterAppender

        encoding, immediateFlush, qw
      • Fields inherited from class org.apache.log4j.AppenderSkeleton

        closed, errorHandler, headFilter, layout, name, tailFilter, threshold
    • Constructor Summary

      Constructors 
      Constructor Description
      TestAppender()  
    • Constructor Detail

      • TestAppender

        public TestAppender()
    • Method Detail

      • enableLogger

        public void enableLogger​(String className)
      • disableLogger

        public void disableLogger​(String className)
      • getInstance

        public static @NonNull TestAppender getInstance()
        Since:
        7.14
      • activateOptions

        public void activateOptions()
        Specified by:
        activateOptions in interface org.apache.log4j.spi.OptionHandler
        Overrides:
        activateOptions in class org.apache.log4j.WriterAppender
        Since:
        7.14
      • close

        public void close()
        Specified by:
        close in interface org.apache.log4j.Appender
        Overrides:
        close in class org.apache.log4j.WriterAppender
      • append

        public void append​(org.apache.log4j.spi.LoggingEvent loggingEvent)
        Overrides:
        append in class org.apache.log4j.WriterAppender
      • getLeastRecentMessageForLogger

        public String getLeastRecentMessageForLogger​(String loggerName)
        Gets the first unread message for the given loggerName. Returns null if no messages have been recorded against the specified logger since the last read.
        Parameters:
        loggerName - logger to read message from
        Returns:
        the first unread message, or null if no new messages