Interface LogContextInitializer


public interface LogContextInitializer
An initializer for log contexts. The initializer provides initial values for log instances within the context for properties like levels, handlers, and so on.

The initial log context will be configured using a context initializer that is located via the JDK SPI mechanism.

This interface is intended to be forward-extensible. If new methods are added, they will include a default implementation. Implementations of this interface should accommodate the possibility of new methods being added; as a matter of convention, such methods should begin with the prefix getInitial, which will minimize the possibility of conflict.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The default log context initializer, which is used when none is specified.
    static final Handler[]
    An array containing zero handlers.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Handler[]
    Get the initial set of handlers to configure for the given logger name.
    default Level
    getInitialLevel(String loggerName)
    Get the initial level for the given logger name.
    default Level
    getMinimumLevel(String loggerName)
    Get the minimum (most verbose) level allowed for the given logger name.
    default boolean
    Establish whether strong references should be used for logger nodes.
  • Field Details

    • NO_HANDLERS

      static final Handler[] NO_HANDLERS
      An array containing zero handlers.
    • DEFAULT

      static final LogContextInitializer DEFAULT
      The default log context initializer, which is used when none is specified. This instance uses only default implementations for all the given methods.
  • Method Details

    • getInitialLevel

      default Level getInitialLevel(String loggerName)
      Get the initial level for the given logger name. If the initializer returns a null level for the root logger, then a level of INFO will be used.

      The default implementation returns null.

      Parameters:
      loggerName - the logger name (must not be null)
      Returns:
      the level to use, or null to inherit the level from the parent
    • getMinimumLevel

      default Level getMinimumLevel(String loggerName)
      Get the minimum (most verbose) level allowed for the given logger name. If the initializer returns a null level for the root logger, then a level of ALL will be used.

      The default implementation returns null.

      Parameters:
      loggerName - the logger name (must not be null)
      Returns:
      the level to use, or null to inherit the level from the parent
    • getInitialHandlers

      default Handler[] getInitialHandlers(String loggerName)
      Get the initial set of handlers to configure for the given logger name.

      The default implementation returns NO_HANDLERS. A value of null is considered to be the same as NO_HANDLERS.

      Parameters:
      loggerName - the logger name (must not be null)
      Returns:
      the handlers to use (should not be null)
    • useStrongReferences

      default boolean useStrongReferences()
      Establish whether strong references should be used for logger nodes.
      Returns:
      true to use strong references, or false to use weak references