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:
logger with a bundleStackTraceElement 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.| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes
PaxLoggingService service tracker in this manager. |
void |
dispose()
Stops using associated
PaxLoggingService reference. |
org.osgi.framework.Bundle |
getBundle()
Returns
Bundle associated with this manager. |
PaxLogger |
getLogger(org.osgi.framework.Bundle bundle,
String category,
String fqcn)
Obtains a
PaxLogger from this manager for a specific Bundle. |
PaxLogger |
getLogger(String category,
String fqcn)
Obtains a
PaxLogger from this manager. |
PaxLoggingService |
getPaxLoggingService()
Returns actual, detected, dynamic
PaxLoggingService that's currently used to obtain
loggers. |
PaxLogger getLogger(String category, String fqcn)
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.category - just name of the loggerfqcn - 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
objectPaxLogger getLogger(org.osgi.framework.Bundle bundle, String category, String fqcn)
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.bundle - Bundle associated with returned PaxLoggercategory - just name of the loggerfqcn - 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
objectPaxLoggingService getPaxLoggingService()
PaxLoggingService that's currently used to obtain
loggers.void close()
PaxLoggingService service tracker in this manager.void dispose()
PaxLoggingService reference.org.osgi.framework.Bundle getBundle()
Bundle associated with this manager. Normally it's pax-logging-api bundle.Copyright © 2006–2023 OPS4J - Open Participation Software for Java. All rights reserved.