Class LogLevelMap


  • public final class LogLevelMap
    extends Object
    A hierarchical mapping from logger name to Level used to override the configured log level during debugging. This class is designed to allow efficient (i.e. zero-allocation) resolution of the log level for a given logger.

    This class is immutable and thread safe.

    • Method Detail

      • builder

        public static LogLevelMap.Builder builder()
        Returns a new builder for constructing a LogLevelMap.
      • create

        public static LogLevelMap create​(Level level)
        Returns an empty LogLevelMap with a single default level which will apply to all loggers.
      • create

        public static LogLevelMap create​(Map<String,​? extends Level> map)
        Returns a LogLevelMap whose entries correspond to the given map, and with the default value of Level.OFF. The keys of the map must all be valid dot-separated logger names, and the values cannot be null.
      • create

        public static LogLevelMap create​(Map<String,​? extends Level> map,
                                         Level defaultLevel)
        Returns a LogLevelMap whose entries correspond to the given map. The keys of the map must all be valid dot-separated logger names, and neither the values, nor the default value, can be null.
      • getLevel

        public Level getLevel​(String loggerName)
        Returns the log level for the specified logger, matching the loggerName to an entry in the map, or the nearest parent in the naming hierarchy. If the given loggerName is invalid, the default value is returned.
      • merge

        public LogLevelMap merge​(LogLevelMap other)
        Returns the union of this map with the given map. Logging is enabled in the merged map if-and-only-if it was enabled in one of the maps it was created from.