Package org.ops4j.pax.logging
Interface PaxLoggingManager
-
- All Known Implementing Classes:
OSGIPaxLoggingManager
public interface PaxLoggingManagerWhile
PaxLoggingServicerepresents implementation-specific logging service, this interface acts as a bridge between logging API specific implementation (like SLF4J LoggerFactory) and actual implementation ofPaxLoggingService. When given service is gone, Logging switches immediately to non-dynamic, fallback implementation ofPaxLoggingService.getLogger()methods in this interface are generic, but low level methods that use 3 parameters to obtain a logger:- bundle - to associate
loggerwith abundle - 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
StackTraceElementof 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%Cor%F.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.
-
-
-
Method Detail
-
getLogger
PaxLogger getLogger(String category, String fqcn)
Obtains 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.- 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
PaxLogger getLogger(org.osgi.framework.Bundle bundle, String category, String fqcn)
Obtains 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.- 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
PaxLoggingService getPaxLoggingService()
Returns actual, detected, dynamicPaxLoggingServicethat's currently used to obtainloggers.- Returns:
-
close
void close()
ClosesPaxLoggingServiceservice tracker in this manager.
-
dispose
void dispose()
Stops using associatedPaxLoggingServicereference.
-
getBundle
org.osgi.framework.Bundle getBundle()
ReturnsBundleassociated with this manager. Normally it's pax-logging-api bundle.- Returns:
-
-