Class LoggingScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Component
    @Named("logging")
    @Singleton
    public class LoggingScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Provide logging related script oriented APIs.
    Since:
    4.2M3
    Version:
    $Id: fa33bd99210b474989898445126dfb98ae68b091 $
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void deprecate​(String loggerName, String message)
      Log a deprecated message, only if the LoggerConfiguration.isDeprecatedLogEnabled() is true.
      org.xwiki.logging.LogLevel getLevel​(String loggerName)  
      Map<String,​org.xwiki.logging.LogLevel> getLevels()  
      org.slf4j.Logger getLogger​(String name)
      Return a logger named according to the name parameter.
      void setLevel​(String logger, org.xwiki.logging.LogLevel level)  
      org.xwiki.logging.LogTree toLogTree​(Iterable<org.xwiki.logging.event.LogEvent> logs)
      Create a tree representation of a series of logs.
      org.xwiki.logging.event.LogEvent translate​(org.xwiki.logging.event.LogEvent logEvent)
      Translate the passed LogEvent based on the translation message corresponding to the translation key stored in the LogEvent.
      org.xwiki.logging.Message translate​(org.xwiki.logging.Message message)
      Translate the passed Message based on the translation message corresponding to the translation key stored in the Message.
    • Constructor Detail

      • LoggingScriptService

        public LoggingScriptService()
    • Method Detail

      • getLogger

        public org.slf4j.Logger getLogger​(String name)
        Return a logger named according to the name parameter.
        Parameters:
        name - The name of the logger.
        Returns:
        logger
        Since:
        6.1RC1
      • getLevels

        public Map<String,​org.xwiki.logging.LogLevel> getLevels()
        Returns:
        all the loggers (usually packages) with corresponding levels.
      • getLevel

        public org.xwiki.logging.LogLevel getLevel​(String loggerName)
        Parameters:
        loggerName - the logger name (usually packages)
        Returns:
        the level associated to the logger
      • setLevel

        public void setLevel​(String logger,
                             org.xwiki.logging.LogLevel level)
        Parameters:
        logger - the logger name (usually package)
        level - the level associated to the logger
      • toLogTree

        public org.xwiki.logging.LogTree toLogTree​(Iterable<org.xwiki.logging.event.LogEvent> logs)
        Create a tree representation of a series of logs.
        Parameters:
        logs - the logs
        Returns:
        the logs as a LogTree
        Since:
        5.4RC1
      • translate

        public org.xwiki.logging.event.LogEvent translate​(org.xwiki.logging.event.LogEvent logEvent)
        Translate the passed LogEvent based on the translation message corresponding to the translation key stored in the LogEvent.

        The translation message pattern use the same syntax than standard message pattern except that it's optionally possible to provide a custom index as in Some {1} translation {0} message in order to modify the order of the argument which can be required depending on the language.

        Parameters:
        logEvent - the LogEvent to translate
        Returns:
        the translated version of the passed LogEvent
      • translate

        @Unstable
        public org.xwiki.logging.Message translate​(org.xwiki.logging.Message message)
        Translate the passed Message based on the translation message corresponding to the translation key stored in the Message.

        The translation message pattern use the same syntax than standard message pattern except that it's optionally possible to provide a custom index as in Some {1} translation {0} message in order to modify the order of the argument which can be required depending on the language.

        Parameters:
        message - the Message to translate
        Returns:
        the translated version of the passed Message
        Since:
        15.0RC1, 14.10.1
      • deprecate

        @Unstable
        public void deprecate​(String loggerName,
                              String message)
        Log a deprecated message, only if the LoggerConfiguration.isDeprecatedLogEnabled() is true. Note that the deprecated message is displayed as a warning with the [DEPRECATED] suffix.
        Parameters:
        loggerName - the name of the logger to be used for the deprecated message.
        message - the message to be displayed for explaining the deprecation.
        Since:
        13.1RC1