Class LoggingSystemTurboFilter

  • All Implemented Interfaces:
    ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.LifeCycle

    public class LoggingSystemTurboFilter
    extends ch.qos.logback.classic.turbo.TurboFilter
    This is our main filter in the logging system. A LogBack TurboFilter is one that is consulted before a log event is generated, for every logging event in the system (so it must be fast!). It has the ability to deny an event before it's generated, or bypass the rest of the filters and automatically accept it.

    Our implementation here is focused on the functionality we add around MDC values. It has the ability to filter based on mdc values, or to emulate logger levels, but for MDC key/values instead of logger names.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  LoggingSystemTurboFilter.MDCKeyFilter
      We can do 2 things: 1) set levels for specific property values (which bypass/ignore logger levels) 2) set property filters, so that events only pass when the property matches.
    • Field Summary

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

        context
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFilter​(java.lang.String key, java.lang.String value)  
      void clear()  
      void clearLevels()  
      ch.qos.logback.core.spi.FilterReply decide​(java.util.Map<java.lang.String,​java.lang.String> mdcMap, ch.qos.logback.classic.Level level, boolean strict)
      This gets called 2 times- one as an actual turbofilter, in which case strict=false, and we only care about promoting events.
      ch.qos.logback.core.spi.FilterReply decide​(org.slf4j.Marker marker, ch.qos.logback.classic.Logger logger, ch.qos.logback.classic.Level level, java.lang.String format, java.lang.Object[] params, java.lang.Throwable t)  
      protected LoggingSystemTurboFilter.MDCKeyFilter getOrCreate​(java.lang.String key)  
      java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​Level>> keyFilterValues()
      Returns the full set of key filters currently applied, in a map with Key Name -> Value Name -> Level hierarchy
      void removeFilter​(java.lang.String key, java.lang.String value)  
      void setLevel​(java.lang.String key, java.lang.String value, ch.qos.logback.classic.Level level)  
      boolean wasAcceptedBy​(ch.qos.logback.classic.spi.ILoggingEvent event)  
      • Methods inherited from class ch.qos.logback.classic.turbo.TurboFilter

        getName, isStarted, setName, start, stop
      • 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, toString, wait, wait, wait
    • Constructor Detail

      • LoggingSystemTurboFilter

        public LoggingSystemTurboFilter()
    • Method Detail

      • keyFilterValues

        public java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​Level>> keyFilterValues()
        Returns the full set of key filters currently applied, in a map with Key Name -> Value Name -> Level hierarchy
        Returns:
        map of currently active filters, its values, and the Levelof the value
      • clear

        public void clear()
      • setLevel

        public void setLevel​(java.lang.String key,
                             java.lang.String value,
                             ch.qos.logback.classic.Level level)
      • clearLevels

        public void clearLevels()
      • addFilter

        public void addFilter​(java.lang.String key,
                              java.lang.String value)
      • removeFilter

        public void removeFilter​(java.lang.String key,
                                 java.lang.String value)
      • decide

        public ch.qos.logback.core.spi.FilterReply decide​(org.slf4j.Marker marker,
                                                          ch.qos.logback.classic.Logger logger,
                                                          ch.qos.logback.classic.Level level,
                                                          java.lang.String format,
                                                          java.lang.Object[] params,
                                                          java.lang.Throwable t)
        Specified by:
        decide in class ch.qos.logback.classic.turbo.TurboFilter
      • wasAcceptedBy

        public boolean wasAcceptedBy​(ch.qos.logback.classic.spi.ILoggingEvent event)
      • decide

        public ch.qos.logback.core.spi.FilterReply decide​(java.util.Map<java.lang.String,​java.lang.String> mdcMap,
                                                          ch.qos.logback.classic.Level level,
                                                          boolean strict)
        This gets called 2 times- one as an actual turbofilter, in which case strict=false, and we only care about promoting events. Then, when strict is true, we're trying to decide what appender hte message should go on. In that case, we must match exactly.