Class LogbackLoggerContext

    • Method Detail

      • setAppender

        public LogbackLoggerContext setAppender​(Appender<ILoggingEvent> appender)
        Sets the single appender for the logger. All existing appenders will first be removed.
        Parameters:
        appender - The appender to set.
        Returns:
        This object.
        Throws:
        NullPointerException - If the given appender is null.
      • removeAppenders

        public LogbackLoggerContext removeAppenders()
        Removes all appenders from the logger.
        Returns:
        This object.
      • useParentAppenders

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

        public LogCaptor<ILoggingEvent> capture()
        Returns an object that captures logged events. This can be used instead of having to append a capturing appender manually.
        Returns:
        An object that captures logged events.
        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.