Interface SilverLoggerFactory

  • All Known Implementing Classes:
    SysLoggerFactory

    public interface SilverLoggerFactory
    A factory of logger instances. It wraps in fact the implementation of the Silverpeas Logging Engine by wrapping and hence using a true logging backend.

    The factory isn't dedicated to be used by client code but by the SilverLogger class to obtain an instance of a logger according to the actual active logging backend. By implementing this interface, the implementor has the total control of any cache mechanism as well as of the loggers manufacture process.

    The bind between the SilverLoggerFactory interface and its implementation is performed by the Java SPI (Java Service Provider Interface). Only the first available logger factory implementation is loaded.

    Author:
    miguel
    • Method Detail

      • get

        static SilverLoggerFactory get()
        Gets an instance of the logger factory. The implementation is provided by the Java Service Provider Interface and this implementation wraps the concrete logging mechanism used by the Silverpeas Logging Engine.
        Returns:
        an instance of a logger factory.
      • getLogger

        default SilverLogger getLogger​(String namespace)
        Gets a SilverLogger instance for the specified namespace. If a logger has already been created with the given namespace it is returned, otherwise a new logger is manufactured and initialized.

        The logging level of the returned logger will be set according to the logging configuration found for the given logger namespace. If no level setting is found from the configuration or if there is no configuration found for the specified namespace, then the logger level is set to null meaning it should inherit its level from its nearest ancestor with a specific (non-null) level value. It is the responsibility of the implementation of the logger to take care of the logging level inheritance and of the default log handlers/adapters used by Silverpeas.

        This method should not be invoked directly. It is dedicated to be used by the SilverLogger.getLogger(String) method or by the implementation of the Silverpeas Logging Engine.

        Parameters:
        namespace - the hierarchical dot-separated namespace of the logger mapping the hierachical relationships between the loggers from the root one.
        Returns:
        a Silverpeas logger instance.
      • getLogger

        SilverLogger getLogger​(String namespace,
                               LoggerConfigurationManager.LoggerConfiguration configuration)
        Gets a SilverLogger instance for the specified namespace. If a logger has already been created with the given namespace it is returned, otherwise a new logger is manufactured and initialized from the given logger configuration.

        The logging level of the returned logger will be set according to the specified logging configuration. If no level setting is found from the configuration or if there is no configuration found for the specified namespace, then the logger level is set to null meaning it should inherit its level from its nearest ancestor with a specific (non-null) level value. It is the responsibility of the implementation of the logger to take care of the logging level inheritance and of the default log handlers/adapters used by Silverpeas.

        This method should not be invoked directly. It is dedicated to be used by the SilverLogger.getLogger(String) method or by the implementation of the Silverpeas Logging Engine.

        Parameters:
        namespace - the hierarchical dot-separated namespace of the logger mapping the hierachical relationships between the loggers from the root one.
        configuration - the logger configuration to use when initializing the manufactured logger. If the logger already exists, the configuration won't be used in order to avoid any replacement of the existing configuration. To update its configuration, please use instead LoggerConfigurationManager.
        Returns:
        a Silverpeas logger instance.