Package org.osgi.service.log
Interface LoggerFactory
- All Known Subinterfaces:
LogService
@ProviderType
public interface LoggerFactory
Logger Factory service for logging information.
Provides methods for bundles to obtain named Loggers that can be used
to write messages to the log.
Logger names should be in the form of a fully qualified Java class names with
segments separated by full stop ('.' \u002E). For example:
com.foo.BarLogger names exist in a hierarchy. A logger name is said to be an ancestor of another logger name if the logger name followed by a full stop (
'.'
\u002E) is a prefix of the descendant logger name. The
root logger name is the top ancestor of the
logger name hierarchy. For example:
com.foo.Bar com.foo com ROOT
- Since:
- 1.4
-
Method Summary
Modifier and TypeMethodDescriptiondefault LoggerReturn theLoggernamed with the specified class.default <L extends Logger>
LReturn theLoggerof the specified type named with the specified class.default LoggerReturn theLoggernamed with the specified name.default <L extends Logger>
LReturn theLoggerof the specified type named with the specified name.default <L extends Logger>
LReturn theLoggerof the specified type named with the specified name for the specified bundle.
-
Method Details
-
getLogger
Return theLoggernamed with the specified name.- Parameters:
name- The name to use for the logger name. Must not benull.- Returns:
- The
Loggernamed with the specified name. If the name parameter is equal toLogger.ROOT_LOGGER_NAME, then the root logger is returned.
-
getLogger
Return theLoggernamed with the specified class.- Parameters:
clazz- The class to use for the logger name. Must not benull.- Returns:
- The
Loggernamed with the name of the specified class.
-
getLogger
Return theLoggerof the specified type named with the specified name.- Type Parameters:
L- The Logger type.- Parameters:
name- The name to use for the logger name. Must not benull.loggerType- The type of Logger. Can beLoggerorFormatterLogger.- Returns:
- The
LoggerorFormatterLoggernamed with the specified name. If the name parameter is equal toLogger.ROOT_LOGGER_NAME, then the root logger is returned. - Throws:
IllegalArgumentException- If the specified type is not a supported Logger type.
-
getLogger
Return theLoggerof the specified type named with the specified class.- Type Parameters:
L- A Logger type.- Parameters:
clazz- The class to use for the logger name. Must not benull.loggerType- The type of Logger. Can beLoggerorFormatterLogger. Must not benull.- Returns:
- The
LoggerorFormatterLoggernamed with the name of the specified class. - Throws:
IllegalArgumentException- If the specified type is not a supported Logger type.
-
getLogger
Return theLoggerof the specified type named with the specified name for the specified bundle.This method is not normally used. The other
getLoggermethods return aLoggerassociated with the bundle used to obtain this Logger Factory service. This method is used to obtain aLoggerfor the specified bundle which may be useful to code which is logging on behalf of another bundle.- Type Parameters:
L- The Logger type.- Parameters:
bundle- The bundle associated with the Logger. Must not benull.name- The name to use for the logger name. Must not benull.loggerType- The type of Logger. Can beLoggerorFormatterLogger. Must not benull.- Returns:
- The
LoggerorFormatterLoggernamed with the specified name for the specified bundle. If the name parameter is equal toLogger.ROOT_LOGGER_NAME, then the root logger is returned. - Throws:
IllegalArgumentException- If the specified type is not a supported Logger type or the specified Bundle is not a resolved bundle.
-