Class LogInterceptor

  • 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 LogInterceptor
    extends ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
    Author:
    Chris Cranford, Jiri Pechanec
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private List<ch.qos.logback.classic.spi.ILoggingEvent> events  
      • 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 
      Modifier Constructor Description
      protected LogInterceptor()
      Constructor using root logger.
        LogInterceptor​(Class<?> clazz)
      Provides a log interceptor based on the logger that emits the message.
        LogInterceptor​(String loggerName)
      Provides a log interceptor based on the logger that emits the message.
    • Field Detail

      • events

        private List<ch.qos.logback.classic.spi.ILoggingEvent> events
    • Constructor Detail

      • LogInterceptor

        protected LogInterceptor()
        Constructor using root logger. This is usually not desirable as disabled additivity can prevent message to get here.
      • LogInterceptor

        public LogInterceptor​(String loggerName)
        Provides a log interceptor based on the logger that emits the message.
        Parameters:
        loggerName - logger that emits the log message
      • LogInterceptor

        public LogInterceptor​(Class<?> clazz)
        Provides a log interceptor based on the logger that emits the message.
        Parameters:
        clazz - class that emits the log message
    • Method Detail

      • append

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

        public void setLoggerLevel​(Class<?> loggerClass,
                                   String level)
      • countOccurrences

        public long countOccurrences​(String text)
      • containsMessage

        public boolean containsMessage​(String text)
      • containsWarnMessage

        public boolean containsWarnMessage​(String text)
      • containsErrorMessage

        public boolean containsErrorMessage​(String text)
      • containsStacktraceElement

        public boolean containsStacktraceElement​(String text)
      • containsMessage

        private boolean containsMessage​(ch.qos.logback.classic.Level level,
                                        String text)