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 Logger
s 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 Logger
Return theLogger
named with the specified class.default <L extends Logger>
LReturn theLogger
of the specified type named with the specified class.default Logger
Return theLogger
named with the specified name.default <L extends Logger>
LReturn theLogger
of the specified type named with the specified name.default <L extends Logger>
LReturn theLogger
of the specified type named with the specified name for the specified bundle.
-
Method Details
-
getLogger
Return theLogger
named with the specified name.- Parameters:
name
- The name to use for the logger name. Must not benull
.- Returns:
- The
Logger
named with the specified name. If the name parameter is equal toLogger.ROOT_LOGGER_NAME
, then the root logger is returned.
-
getLogger
Return theLogger
named with the specified class.- Parameters:
clazz
- The class to use for the logger name. Must not benull
.- Returns:
- The
Logger
named with the name of the specified class.
-
getLogger
Return theLogger
of 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 beLogger
orFormatterLogger
.- Returns:
- The
Logger
orFormatterLogger
named 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 theLogger
of 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 beLogger
orFormatterLogger
. Must not benull
.- Returns:
- The
Logger
orFormatterLogger
named with the name of the specified class. - Throws:
IllegalArgumentException
- If the specified type is not a supported Logger type.
-
getLogger
Return theLogger
of the specified type named with the specified name for the specified bundle.This method is not normally used. The other
getLogger
methods return aLogger
associated with the bundle used to obtain this Logger Factory service. This method is used to obtain aLogger
for 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 beLogger
orFormatterLogger
. Must not benull
.- Returns:
- The
Logger
orFormatterLogger
named 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.
-