Interface LogReaderService
Since 1.4, org.osgi.service.log.stream.LogStreamProvider is the
preferred way to obtain LogEntry objects.
The LogReaderService provides two ways to obtain LogEntry objects:
- The primary way to retrieve
LogEntryobjects is to register aLogListenerobject whoseLogListener.logged(LogEntry)method will be called for each entry added to the log. - To obtain past
LogEntryobjects, thegetLog()method can be called which will return anEnumerationof theLogEntryobjects in the log.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddLogListener(LogListener listener) Subscribes toLogEntryobjects.getLog()Returns anEnumerationof theLogEntryobjects in the log.voidremoveLogListener(LogListener listener) Unsubscribes toLogEntryobjects.
-
Method Details
-
addLogListener
Subscribes toLogEntryobjects.This method registers a
LogListenerobject with the Log Reader Service. TheLogListener.logged(LogEntry)method will be called for eachLogEntryobject placed into the log.When a bundle which registers a
LogListenerobject is stopped or otherwise releases the Log Reader Service, the Log Reader Service must remove all of the bundle's listeners.If this Log Reader Service's list of listeners already contains a listener
lsuch that(l==listener), this method does nothing.Since 1.4,
org.osgi.service.log.stream.LogStreamProvideris the preferred way to obtainLogEntryobjects.- Parameters:
listener- ALogListenerobject to register; theLogListenerobject is used to receiveLogEntryobjects.
-
removeLogListener
Unsubscribes toLogEntryobjects.This method unregisters a
LogListenerobject from the Log Reader Service.If
listeneris not contained in this Log Reader Service's list of listeners, this method does nothing.Since 1.4,
org.osgi.service.log.stream.LogStreamProvideris the preferred way to obtainLogEntryobjects.- Parameters:
listener- ALogListenerobject to unregister.
-
getLog
Enumeration<LogEntry> getLog()Returns anEnumerationof theLogEntryobjects in the log.Each element of the enumeration is a
LogEntryobject, ordered with the most recent entry first. Whether the enumeration is of allLogEntryobjects since the Log Service was started or some recent past is implementation-specific.- Returns:
- An
Enumerationof theLogEntryobjects in the log.
-