Package org.ops4j.pax.logging
Class OSGIPaxLoggingManager
- java.lang.Object
-
- org.ops4j.pax.logging.OSGIPaxLoggingManager
-
- All Implemented Interfaces:
PaxLoggingManager,org.osgi.util.tracker.ServiceTrackerCustomizer<PaxLoggingService,PaxLoggingService>
public class OSGIPaxLoggingManager extends Object implements PaxLoggingManager, org.osgi.util.tracker.ServiceTrackerCustomizer<PaxLoggingService,PaxLoggingService>
PaxLoggingManagerthat acts as a singleton that delegates to tracked instance ofPaxLoggingServiceMore precisely - it returns instances ofPaxLoggerthat internally delegate to loggers obtained from availablePaxLoggingServiceor from fallback service when there's no implementation available.
-
-
Constructor Summary
Constructors Constructor Description OSGIPaxLoggingManager(org.osgi.framework.BundleContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PaxLoggingServiceaddingService(org.osgi.framework.ServiceReference<PaxLoggingService> reference)voidclose()ClosesPaxLoggingServiceservice tracker in this manager.voiddispose()Stops using associatedPaxLoggingServicereference.org.osgi.framework.BundlegetBundle()ReturnsBundleassociated with this manager.PaxLoggergetLogger(String category, String fqcn)Obtains aPaxLoggerfrom this manager.PaxLoggergetLogger(org.osgi.framework.Bundle bundle, String category, String fqcn)Obtains aPaxLoggerfrom this manager for a specificBundle.PaxLoggingServicegetPaxLoggingService()Returns actual, detected, dynamicPaxLoggingServicethat's currently used to obtainloggers.voidmodifiedService(org.osgi.framework.ServiceReference<PaxLoggingService> reference, PaxLoggingService service)voidremovedService(org.osgi.framework.ServiceReference<PaxLoggingService> reference, PaxLoggingService service)
-
-
-
Method Detail
-
getLogger
public PaxLogger getLogger(String category, String fqcn)
Description copied from interface:PaxLoggingManagerObtains aPaxLoggerfrom this manager. Implementation delegates toPaxLoggingServiceor to fallback logger provider. This is the main method called inside any facade/bridge method (like SLF4J'sLoggerFactory.getLogger()).fqcnparameter will be part of the returnedPaxLoggerto determine the location where logging method is invoked (by analyzing stack/class trace). EachPaxLoggerhas associatedBundle, butfqcnwon't be used to determine the bundle. Bundle is determined statically when obtaining theloggeras 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 specificHandler.- Specified by:
getLoggerin interfacePaxLoggingManager- Parameters:
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 viaLogServiceand not through concrete logger object- Returns:
-
getLogger
public PaxLogger getLogger(org.osgi.framework.Bundle bundle, String category, String fqcn)
Description copied from interface:PaxLoggingManagerObtains aPaxLoggerfrom this manager for a specificBundle. Implementation delegates toPaxLoggingServiceor to fallback logger provider.fqcnparameter will be part of the returnedPaxLoggerto determine the location where logging method is invoked (by analyzing stack/class trace). This method passes aBundleto associate with returnedPaxLogger. Note that for java.util.logging, the logger is not directly obtained by "client" code, but rather in pax-logging specificHandler.- Specified by:
getLoggerin interfacePaxLoggingManager- Parameters:
bundle-Bundleassociated with returnedPaxLoggercategory- 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 viaLogServiceand not through concrete logger object- Returns:
-
getPaxLoggingService
public PaxLoggingService getPaxLoggingService()
Description copied from interface:PaxLoggingManagerReturns actual, detected, dynamicPaxLoggingServicethat's currently used to obtainloggers.- Specified by:
getPaxLoggingServicein interfacePaxLoggingManager- Returns:
-
close
public void close()
Description copied from interface:PaxLoggingManagerClosesPaxLoggingServiceservice tracker in this manager.- Specified by:
closein interfacePaxLoggingManager
-
dispose
public void dispose()
Description copied from interface:PaxLoggingManagerStops using associatedPaxLoggingServicereference.- Specified by:
disposein interfacePaxLoggingManager
-
getBundle
public org.osgi.framework.Bundle getBundle()
Description copied from interface:PaxLoggingManagerReturnsBundleassociated with this manager. Normally it's pax-logging-api bundle.- Specified by:
getBundlein interfacePaxLoggingManager- Returns:
-
addingService
public PaxLoggingService addingService(org.osgi.framework.ServiceReference<PaxLoggingService> reference)
- Specified by:
addingServicein interfaceorg.osgi.util.tracker.ServiceTrackerCustomizer<PaxLoggingService,PaxLoggingService>
-
modifiedService
public void modifiedService(org.osgi.framework.ServiceReference<PaxLoggingService> reference, PaxLoggingService service)
- Specified by:
modifiedServicein interfaceorg.osgi.util.tracker.ServiceTrackerCustomizer<PaxLoggingService,PaxLoggingService>
-
removedService
public void removedService(org.osgi.framework.ServiceReference<PaxLoggingService> reference, PaxLoggingService service)
- Specified by:
removedServicein interfaceorg.osgi.util.tracker.ServiceTrackerCustomizer<PaxLoggingService,PaxLoggingService>
-
-