Class JdkLoggerContext

    • Method Detail

      • setLevel

        public JdkLoggerContext setLevel​(Level level)
        Sets the new level for the logger.
        Parameters:
        level - The new level.
        Returns:
        This object.
        Throws:
        NullPointerException - If the given level is null.
      • addHandler

        public JdkLoggerContext addHandler​(Handler handler)
        Adds a handler to the logger.
        Parameters:
        handler - The handler to add.
        Returns:
        This object.
        Throws:
        NullPointerException - If the given handler is null.
      • setHandler

        public JdkLoggerContext setHandler​(Handler handler)
        Sets the single handler for the logger. All existing handlers will first be removed.
        Parameters:
        handler - The handler to set.
        Returns:
        This object.
        Throws:
        NullPointerException - If the given handler is null.
      • removeHandler

        public JdkLoggerContext removeHandler​(Handler handler)
        Removes a handler from the logger.
        Parameters:
        handler - The handler to remove.
        Returns:
        This object.
        Throws:
        NullPointerException - If the given handler is null.
      • removeHandlers

        public JdkLoggerContext removeHandlers()
        Removes all handlers from the logger.
        Returns:
        This object.
      • removeHandlers

        public JdkLoggerContext removeHandlers​(Predicate<? super Handler> filter)
        Removes all handlers from the logger that match a filter.
        Parameters:
        filter - The filter to use.
        Returns:
        This object.
        Throws:
        NullPointerException - If the given filter is null.
      • useParentHandlers

        public JdkLoggerContext useParentHandlers​(boolean useParentHandlers)
        Sets whether or not to use parent handlers for the logger.
        Parameters:
        useParentHandlers - true to use parent handlers, false otherwise.
        Returns:
        This object.
      • capture

        public LogCaptor<LogRecord> capture()
        Returns an object that captures logged records. This can be used instead of having to append a capturing handler manually.
        Returns:
        An object that captures logged records.
        Since:
        3.0
      • restore

        public void restore()
        Restores the original settings of the logger.

        It should usually not be necessary to call this method, as it will be called automatically once this context goes out of scope.