Interface PaxLoggingManager

  • All Known Implementing Classes:
    OSGIPaxLoggingManager

    public interface PaxLoggingManager

    While PaxLoggingService represents implementation-specific logging service, this interface acts as a bridge between logging API specific implementation (like SLF4J LoggerFactory) and actual implementation of PaxLoggingService. When given service is gone, Logging switches immediately to non-dynamic, fallback implementation of PaxLoggingService.

    getLogger() methods in this interface are generic, but low level methods that use 3 parameters to obtain a logger:

    • bundle - to associate logger with a bundle
    • category - to name a logger using well known, usually dot-separated, convention
    • fqcn - fully qualified class name, which is not the same as category. It generally should be used to mark a class name in StackTraceElement of stack trace where application code enters logging infrastructure. This was used for example by Log4J1 to discover a location - class name, method name, file name and line number when pattern contains %C or %F.
    • Method Detail

      • getLogger

        PaxLogger getLogger​(String category,
                            String fqcn)
        Obtains a PaxLogger from this manager. Implementation delegates to PaxLoggingService or to fallback logger provider. This is the main method called inside any facade/bridge method (like SLF4J's LoggerFactory.getLogger()). fqcn parameter will be part of the returned PaxLogger to determine the location where logging method is invoked (by analyzing stack/class trace). Each PaxLogger has associated Bundle, but fqcn won't be used to determine the bundle. Bundle is determined statically when obtaining the logger as first bundle that's not pax-logging-api and represents a bundle that created the logger - not a place where this logger is used to log messages. Note that for java.util.logging, the logger is not directly obtained by "client" code, but rather in pax-logging specific Handler.
        Parameters:
        category - just name of the logger
        fqcn - fully qualified name for pax-logging-specific factory-like class to make it easy to mark where (in the stack trace) user code calls logging code. It doesn't always make sense - mainly in dynamic scenarios where logging is invoked via LogService and not through concrete logger object
        Returns:
      • getLogger

        PaxLogger getLogger​(org.osgi.framework.Bundle bundle,
                            String category,
                            String fqcn)
        Obtains a PaxLogger from this manager for a specific Bundle. Implementation delegates to PaxLoggingService or to fallback logger provider. fqcn parameter will be part of the returned PaxLogger to determine the location where logging method is invoked (by analyzing stack/class trace). This method passes a Bundle to associate with returned PaxLogger. Note that for java.util.logging, the logger is not directly obtained by "client" code, but rather in pax-logging specific Handler.
        Parameters:
        bundle - Bundle associated with returned PaxLogger
        category - just name of the logger
        fqcn - fully qualified name for pax-logging-specific factory-like class to make it easy to mark where (in the stack trace) user code calls logging code. It doesn't always make sense - mainly in dynamic scenarios where logging is invoked via LogService and not through concrete logger object
        Returns:
      • getBundle

        org.osgi.framework.Bundle getBundle()
        Returns Bundle associated with this manager. Normally it's pax-logging-api bundle.
        Returns: