interface allows bundle developers to log messages that can be distributed to other bundles, which in turn can forward the logged entries to a file system, remote system, or some other destination.
interface allows the bundle developer to:
- Specify a message and/or exception to be logged.
- Supply a log level representing the severity of the message being logged. This should be one of the levels defined in the LogService interface but it may be any integer that is interpreted in a user-defined way.
- Specify the Service associated with the log requests. By obtaining a LogService object from the Framework service registry, a bundle can start logging messages to the LogService object by calling one of the LogService methods. A Log Service object can log any message, but it is primarily intended for reporting events and error conditions.
interface defines these methods for logging messages:
- log(int, String) – This method logs a simple message at a given log level.
- log(int, String, Throwable) – This method logs a message with an exception at a given log level.
- log(ServiceReference, int, String) – This method logs a message associated with a specific service.
- log(ServiceReference, int, String, Throwable) – This method logs a message with an exception associated with a specific service.
While it is possible for a bundle to call one of the log methods without providing ServiceReference
object, it is recommended that the caller supply the ServiceReference
argument whenever appropriate, because it provides important context information to the operator in the event of problems.
For more information on the OSGi Logging APIs please see the OSGi_R4_Service_Compendium, specifically the OSGi Log Service Specification chapter.
Parent topic: Developing serviceability logic: XPD621