Interface LoggerManager


  • @Role
    public interface LoggerManager
    Provide some logging management APIs such as the ability to redirect logs to an EventListener.
    Since:
    3.2M3
    Version:
    $Id: a54eb022298b899f57367b623044422b062161fb $
    • Method Detail

      • pushLogListener

        void pushLogListener​(EventListener listener)
        Grab subsequent logs produced by the current thread and send them to the provided listener.

        Note that the logs generated by the current thread will not be output anymore by the logging system implementing the SLF4J API (Technically, this is done, for example when the implementation is LogBack, by dynamically replacing the LogBack appender with our own).

        After this method is called, logs will be only be received as XWiki events sent to the provided listener. In addition, it also overrides any previous call to pushLogListener(EventListener) (which will get active again after a call to popLogListener()).

        Parameters:
        listener - the listener that will receive all future logging events
      • popLogListener

        EventListener popLogListener()
        Remove the current listener from the current thread stack.

        If several listeners have been pushed it makes the previous one active again.

        Returns:
        the previous log events listener for the current thread
      • setLoggerLevel

        void setLoggerLevel​(String loggerName,
                            LogLevel level)
        Associate the passed logger to the passed log level.
        Parameters:
        loggerName - the logger
        level - the level of the logger
      • getLoggerLevel

        LogLevel getLoggerLevel​(String loggerName)
        Parameters:
        loggerName - the logger
        Returns:
        the log level associated to the logger, return null if the level is inherited from parent logger
      • getLoggers

        Collection<org.slf4j.Logger> getLoggers()
        Returns:
        all the registered loggers
      • createLoggerTail

        default LoggerTail createLoggerTail​(Path file,
                                            boolean readonly)
                                     throws IOException
        Create a LoggerTail in charge of navigating and appending the passed file with logs.
        Parameters:
        file - the file where to store the log
        readonly - true of the log is read only
        Returns:
        the LoggerTail instance
        Throws:
        IOException - when failing to open the LoggerTail
        Since:
        11.9RC1