Class LoggerConfigurationManager

java.lang.Object
org.silverpeas.kernel.logging.LoggerConfigurationManager

@Technical public class LoggerConfigurationManager extends Object
There is a single global LoggerConfigurationManager object that is used to manage a set of configuration about the different Loggers available in Silverpeas. This single instance can only be got from the SilverLoggerProvider object.

Each logger in Silverpeas is usually mapped to a given Silverpeas module. A Silverpeas module is a functional component in Silverpeas. The component can provide a service to others components or implement a business service for the end user. By defining a mapping between a module and a logger, when some objects write some messages into a log, only the name of the module in which these objects belong is required to figure out what logger to use; it is hence no necessary to remind the schema of the loggers namespace in use in Silverpeas. Each mapping is defined in a logging configuration file (a Java properties file) with optionally, as property, the logging level to use for the mapped logger.

A logging configuration for a Silverpeas module is stored into a properties file that must be located in the loggers root directory indicated by SilverpeasResourcesLocation.getLoggersRootPath(). The following properties are expected into such a file:

  • namespace: the hierarchical path of the logger in which each node is separated by a dot
  • level: optional property indicating the level of traces of the logger. If not set, the level is figuring out by coming upward to the nearest parent logger for which a level is defined.
Author:
mmoquillon
API Note:
It isn't possible to instantiate explicitly this class. To get a LoggerConfigurationManager instance, you should ask to the SilverLoggerProvider single instance.
Implementation Note:
The loading of the loggers configuration isn't done at instantiation; it has to be invoked explicitly. The instantiation of a LoggerConfigurationManager is performed by the SilverLoggerProvider single instance.
  • Constructor Details

    • LoggerConfigurationManager

      protected LoggerConfigurationManager()
  • Method Details

    • loadAllConfigurationFiles

      protected void loadAllConfigurationFiles()
    • getLoggerConfiguration

      public LoggerConfigurationManager.LoggerConfiguration getLoggerConfiguration(String namespace)
      Gets the configuration parameters for the logger with the specified namespace.
      Parameters:
      namespace - a logger namespace.
      Returns:
      the configuration of the logger defined for the specified namespace.
    • saveLoggerConfiguration

      public void saveLoggerConfiguration(LoggerConfigurationManager.LoggerConfiguration configuration)
      Saves the configuration of the logger referred by the specified configuration instance.

      If no configuration exists for the logger referred by the configuration object, then nothing is done.

      Parameters:
      configuration - the new configuration of the logger defined for the specified Silverpeas module.
    • getAvailableLoggerConfigurations

      public Set<LoggerConfigurationManager.LoggerConfiguration> getAvailableLoggerConfigurations()
      Gets the available configuration of all the Silverpeas loggers. If a logger has no configuration file, then it isn't taken into account.
      Returns:
      a set of logger configurations sorted by logger namespace.