Class ClogrContextSelector

java.lang.Object
io.clogr.logback.ClogrContextSelector
All Implemented Interfaces:
ch.qos.logback.classic.selector.ContextSelector

public class ClogrContextSelector extends Object implements ch.qos.logback.classic.selector.ContextSelector
A Logback context selector that uses Clogr to get the current logging context.
Author:
Garret Wilson
API Note:
As of Logback 1.3.0-alpha4 Logback no longer supports the ContextSelector mechanism for logging separation. See LOGBACK-1196 to track whether it will be reinstated in the future.
Implementation Specification:
This implementation does not support named contexts and returns an empty list.
  • Constructor Details

    • ClogrContextSelector

      public ClogrContextSelector(@Nonnull ch.qos.logback.classic.LoggerContext loggerContext)
      Logger context constructor.
      Parameters:
      loggerContext - The default logger context.
  • Method Details

    • getDefaultLoggerContext

      public ch.qos.logback.classic.LoggerContext getDefaultLoggerContext()
      Specified by:
      getDefaultLoggerContext in interface ch.qos.logback.classic.selector.ContextSelector
    • getLoggerContext

      public ch.qos.logback.classic.LoggerContext getLoggerContext()
      Specified by:
      getLoggerContext in interface ch.qos.logback.classic.selector.ContextSelector
      Implementation Specification:
      This implementation uses Clogr to retrieve the current logger context.
      Throws:
      ClassCastException - if the current logging concern is not an instance of LoggerContextLoggingConcern.
      See Also:
      • Clogr.getLoggingConcern()
    • detachLoggerContext

      public ch.qos.logback.classic.LoggerContext detachLoggerContext(String loggerContextName)
      Specified by:
      detachLoggerContext in interface ch.qos.logback.classic.selector.ContextSelector
      Implementation Specification:
      This implementation does not support named contexts and returns null.
    • getContextNames

      public List<String> getContextNames()
      Specified by:
      getContextNames in interface ch.qos.logback.classic.selector.ContextSelector
      Implementation Specification:
      This implementation does not support named contexts and returns an empty list.
    • getLoggerContext

      public ch.qos.logback.classic.LoggerContext getLoggerContext(String name)
      Specified by:
      getLoggerContext in interface ch.qos.logback.classic.selector.ContextSelector
      Implementation Specification:
      This implementation does not support named contexts and returns null.