Top Description Methods
org.osgi.service.log

public Interface LoggerFactory

Known Direct Subinterfaces
org.osgi.service.log.LogService
Annotations
@ProviderType
Imports
org.osgi.annotation.versioning.ProviderType, org.osgi.framework.Bundle

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.Bar
Logger 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
Author
$Id: 756540e45fd79c3343529926f9cb2114ff53a101 $
Since
1.4

Method Summary

Modifier and TypeMethod and Description
public Logger

Returns:

The Logger named with the specified name. If the name parameter is equal to Logger#ROOT_LOGGER_NAME, then the root logger is returned.
getLogger
(String
The name to use for the logger name. Must not be null.
name
)

Return the Logger named with the specified name.

public Logger

Returns:

The Logger named with the name of the specified class.
getLogger
(Class<?>
The class to use for the logger name. Must not be null.
clazz
)

Return the Logger named with the specified class.

public <
The Logger type.
L extends Logger
>
L

Returns:

The Logger or FormatterLogger named with the specified name. If the name parameter is equal to Logger#ROOT_LOGGER_NAME, then the root logger is returned.
getLogger
(String
The name to use for the logger name. Must not be null.
name
,
Class<L>
The type of Logger. Can be Logger or FormatterLogger.
loggerType
)

Return the Logger of the specified type named with the specified name.

public <
A Logger type.
L extends Logger
>
L

Returns:

The Logger or FormatterLogger named with the name of the specified class.
getLogger
(Class<?>
The class to use for the logger name. Must not be null.
clazz
,
Class<L>
The type of Logger. Can be Logger or FormatterLogger. Must not be null.
loggerType
)

Return the Logger of the specified type named with the specified class.

public <
The Logger type.
L extends Logger
>
L

Returns:

The Logger or FormatterLogger named with the specified name for the specified bundle. If the name parameter is equal to Logger#ROOT_LOGGER_NAME, then the root logger is returned.
getLogger
(Bundle
The bundle associated with the Logger. Must not be null.
bundle
,
String
The name to use for the logger name. Must not be null.
name
,
Class<L>
The type of Logger. Can be Logger or FormatterLogger. Must not be null.
loggerType
)

Return the Logger of the specified type named with the specified name for the specified bundle.

Method Detail

getLoggerback to summary
public Logger getLogger(String name)

Return the Logger named with the specified name.

Parameters
name:String

The name to use for the logger name. Must not be null.

Returns:Logger

The Logger named with the specified name. If the name parameter is equal to Logger#ROOT_LOGGER_NAME, then the root logger is returned.

getLoggerback to summary
public Logger getLogger(Class<?> clazz)

Return the Logger named with the specified class.

Parameters
clazz:Class<?>

The class to use for the logger name. Must not be null.

Returns:Logger

The Logger named with the name of the specified class.

getLoggerback to summary
public <L extends Logger> L getLogger(String name, Class<L> loggerType)

Return the Logger of the specified type named with the specified name.

Parameters
<L>
The Logger type.
name:String

The name to use for the logger name. Must not be null.

loggerType:Class<L>

The type of Logger. Can be Logger or FormatterLogger.

Returns:L

The Logger or FormatterLogger named with the specified name. If the name parameter is equal to Logger#ROOT_LOGGER_NAME, then the root logger is returned.

Exceptions
IllegalArgumentException:
If the specified type is not a supported Logger type.
getLoggerback to summary
public <L extends Logger> L getLogger(Class<?> clazz, Class<L> loggerType)

Return the Logger of the specified type named with the specified class.

Parameters
<L>
A Logger type.
clazz:Class<?>

The class to use for the logger name. Must not be null.

loggerType:Class<L>

The type of Logger. Can be Logger or FormatterLogger. Must not be null.

Returns:L

The Logger or FormatterLogger named with the name of the specified class.

Exceptions
IllegalArgumentException:
If the specified type is not a supported Logger type.
getLoggerback to summary
public <L extends Logger> L getLogger(Bundle bundle, String name, Class<L> loggerType)

Return the Logger of the specified type named with the specified name for the specified bundle.

This method is not normally used. The other getLogger methods return a Logger associated with the bundle used to obtain this Logger Factory service. This method is used to obtain a Logger for the specified bundle which may be useful to code which is logging on behalf of another bundle.

Parameters
<L>
The Logger type.
bundle:Bundle

The bundle associated with the Logger. Must not be null.

name:String

The name to use for the logger name. Must not be null.

loggerType:Class<L>

The type of Logger. Can be Logger or FormatterLogger. Must not be null.

Returns:L

The Logger or FormatterLogger named with the specified name for the specified bundle. If the name parameter is equal to Logger#ROOT_LOGGER_NAME, then the root logger is returned.

Exceptions
IllegalArgumentException:
If the specified type is not a supported Logger type or the specified Bundle is not a resolved bundle.