public class OSGIPaxLoggingManager extends Object implements PaxLoggingManager, org.osgi.util.tracker.ServiceTrackerCustomizer<PaxLoggingService,PaxLoggingService>
PaxLoggingManager that acts as a singleton that delegates to tracked instance of PaxLoggingService
More precisely - it returns instances of PaxLogger that internally delegate to loggers obtained from
available PaxLoggingService or from fallback service when there's no implementation available.
| Constructor and Description |
|---|
OSGIPaxLoggingManager(org.osgi.framework.BundleContext context) |
| Modifier and Type | Method and Description |
|---|---|
PaxLoggingService |
addingService(org.osgi.framework.ServiceReference<PaxLoggingService> reference) |
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. |
void |
modifiedService(org.osgi.framework.ServiceReference<PaxLoggingService> reference,
PaxLoggingService service) |
void |
removedService(org.osgi.framework.ServiceReference<PaxLoggingService> reference,
PaxLoggingService service) |
public OSGIPaxLoggingManager(org.osgi.framework.BundleContext context)
public PaxLogger getLogger(String category, String fqcn)
PaxLoggingManagerObtains 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.
getLogger in interface PaxLoggingManagercategory - 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
objectpublic PaxLogger getLogger(org.osgi.framework.Bundle bundle, String category, String fqcn)
PaxLoggingManagerObtains 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.
getLogger in interface PaxLoggingManagerbundle - 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
objectpublic PaxLoggingService getPaxLoggingService()
PaxLoggingManagerPaxLoggingService that's currently used to obtain
loggers.getPaxLoggingService in interface PaxLoggingManagerpublic void close()
PaxLoggingManagerPaxLoggingService service tracker in this manager.close in interface PaxLoggingManagerpublic void dispose()
PaxLoggingManagerPaxLoggingService reference.dispose in interface PaxLoggingManagerpublic org.osgi.framework.Bundle getBundle()
PaxLoggingManagerBundle associated with this manager. Normally it's pax-logging-api bundle.getBundle in interface PaxLoggingManagerpublic PaxLoggingService addingService(org.osgi.framework.ServiceReference<PaxLoggingService> reference)
addingService in interface org.osgi.util.tracker.ServiceTrackerCustomizer<PaxLoggingService,PaxLoggingService>public void modifiedService(org.osgi.framework.ServiceReference<PaxLoggingService> reference, PaxLoggingService service)
modifiedService in interface org.osgi.util.tracker.ServiceTrackerCustomizer<PaxLoggingService,PaxLoggingService>public void removedService(org.osgi.framework.ServiceReference<PaxLoggingService> reference, PaxLoggingService service)
removedService in interface org.osgi.util.tracker.ServiceTrackerCustomizer<PaxLoggingService,PaxLoggingService>Copyright © 2006–2020 OPS4J - Open Participation Software for Java. All rights reserved.