Interface LoggerFactory

  • All Known Subinterfaces:
    LogService

    @ProviderType
    public interface LoggerFactory
    Logger Factory service for logging information.

    Provides methods for bundles to obtain named Loggers that can be used to write messages to the log.

    Logger names should be in the form of a fully qualified Java class names with segments separated by full stop ('.' \u002E). For example:

     com.foo.Bar
     
    Logger names exist in a hierarchy. A logger name is said to be an ancestor of another logger name if the logger name followed by a full stop ('.' \u002E) is a prefix of the descendant logger name. The root logger name is the top ancestor of the logger name hierarchy. For example:
     com.foo.Bar
     com.foo
     com
     ROOT
     
    Since:
    1.4
    • Method Summary

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default Logger getLogger​(java.lang.Class<?> clazz)
      Return the Logger named with the specified class.
      default <L extends Logger>
      L
      getLogger​(java.lang.Class<?> clazz, java.lang.Class<L> loggerType)
      Return the Logger of the specified type named with the specified class.
      default Logger getLogger​(java.lang.String name)
      Return the Logger named with the specified name.
      default <L extends Logger>
      L
      getLogger​(java.lang.String name, java.lang.Class<L> loggerType)
      Return the Logger of the specified type named with the specified name.
      default <L extends Logger>
      L
      getLogger​(org.osgi.framework.Bundle bundle, java.lang.String name, java.lang.Class<L> loggerType)
      Return the Logger of the specified type named with the specified name for the specified bundle.
    • Method Detail

      • getLogger

        default Logger getLogger​(java.lang.String name)
        Return the Logger named with the specified name.
        Parameters:
        name - The name to use for the logger name.
        Returns:
        The Logger named with the specified name. If the name parameter is equal to Logger.ROOT_LOGGER_NAME, then the root logger is returned.
      • getLogger

        default Logger getLogger​(java.lang.Class<?> clazz)
        Return the Logger named with the specified class.
        Parameters:
        clazz - The class to use for the logger name.
        Returns:
        The Logger named with the name of the specified class.
      • getLogger

        default <L extends Logger> L getLogger​(java.lang.String name,
                                               java.lang.Class<L> loggerType)
        Return the Logger of the specified type named with the specified name.
        Type Parameters:
        L - The Logger type.
        Parameters:
        name - The name to use for the logger name.
        loggerType - The type of Logger. Can be Logger or FormatterLogger.
        Returns:
        The Logger or FormatterLogger named with the specified name. If the name parameter is equal to Logger.ROOT_LOGGER_NAME, then the root logger is returned.
        Throws:
        java.lang.IllegalArgumentException - If the specified type is not a supported Logger type.
      • getLogger

        default <L extends Logger> L getLogger​(java.lang.Class<?> clazz,
                                               java.lang.Class<L> loggerType)
        Return the Logger of the specified type named with the specified class.
        Type Parameters:
        L - A Logger type.
        Parameters:
        clazz - The class to use for the logger name.
        loggerType - The type of Logger. Can be Logger or FormatterLogger.
        Returns:
        The Logger or FormatterLogger named with the name of the specified class.
        Throws:
        java.lang.IllegalArgumentException - If the specified type is not a supported Logger type.
      • getLogger

        default <L extends Logger> L getLogger​(org.osgi.framework.Bundle bundle,
                                               java.lang.String name,
                                               java.lang.Class<L> loggerType)
        Return the Logger of the specified type named with the specified name for the specified bundle.

        This method is not normally used. The other getLogger methods return a Logger associated with the bundle used to obtain this Logger Factory service. This method is used to obtain a Logger for the specified bundle which may be useful to code which is logging on behalf of another bundle.

        Type Parameters:
        L - The Logger type.
        Parameters:
        bundle - The bundle associated with the Logger.
        name - The name to use for the logger name.
        loggerType - The type of Logger. Can be Logger or FormatterLogger.
        Returns:
        The Logger or FormatterLogger named with the specified name for the specified bundle. If the name parameter is equal to Logger.ROOT_LOGGER_NAME, then the root logger is returned.
        Throws:
        java.lang.IllegalArgumentException - If the specified type is not a supported Logger type or the specified Bundle is not a resolved bundle.