Class Logger
- All Implemented Interfaces:
LoggerFactory,LogService,ServiceTrackerCustomizer
This Logger class represents ServiceTracker for LogService. It provides a simple mechanism for interacting with the log service.
- See Also:
-
Field Summary
Fields inherited from interface org.osgi.service.log.LogService
LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARNING -
Constructor Summary
ConstructorsConstructorDescriptionLogger(BundleContext context) Constructs new Logger(ServiceTracker for LogService). -
Method Summary
Modifier and TypeMethodDescriptionvoidLogs a message.voidLogs a message with an exception.voidlog(ServiceReference ref, int level, String message) Logs a message associated with a specificServiceReferenceobject.voidlog(ServiceReference ref, int level, String message, Throwable exception) Logs a message with an exception associated and aServiceReferenceobject.Methods inherited from class org.osgi.util.tracker.ServiceTracker
addingService, close, getService, getService, getServiceReference, getServiceReferences, getServices, getServices, getTracked, getTrackingCount, isEmpty, modifiedService, open, open, remove, removedService, size, waitForService
-
Constructor Details
-
Logger
Constructs new Logger(ServiceTracker for LogService).- Parameters:
context- bundle context.
-
-
Method Details
-
log
Description copied from interface:LogServiceLogs a message.The
ServiceReferencefield and theThrowablefield of theLogEntryobject will be set tonull.This method will log to the
Loggernamed"LogService"for the bundle. The specified level is mapped to aLogLevelas follows:LogService.LOG_ERROR-LogLevel.ERRORLogService.LOG_WARNING-LogLevel.WARNLogService.LOG_INFO-LogLevel.INFOLogService.LOG_DEBUG-LogLevel.DEBUG- Any other value -
LogLevel.TRACE
LogEntry.getLevel()must return the specified level.- Specified by:
login interfaceLogService- Parameters:
level- The severity of the message. This should be one of the defined log levels but may be any integer that is interpreted in a user defined way.message- Human readable string describing the condition ornull.- See Also:
-
log
Description copied from interface:LogServiceLogs a message with an exception.The
ServiceReferencefield of theLogEntryobject will be set tonull.This method will log to the
Loggernamed"LogService"for the bundle. The specified level is mapped to aLogLevelas follows:LogService.LOG_ERROR-LogLevel.ERRORLogService.LOG_WARNING-LogLevel.WARNLogService.LOG_INFO-LogLevel.INFOLogService.LOG_DEBUG-LogLevel.DEBUG- Any other value -
LogLevel.TRACE
LogEntry.getLevel()must return the specified level.- Specified by:
login interfaceLogService- Parameters:
level- The severity of the message. This should be one of the defined log levels but may be any integer that is interpreted in a user defined way.message- The human readable string describing the condition ornull.exception- The exception that reflects the condition ornull.- See Also:
-
log
Description copied from interface:LogServiceLogs a message associated with a specificServiceReferenceobject.The
Throwablefield of theLogEntrywill be set tonull.This method will log to the
Loggernamed"LogService"for the bundle. The specified level is mapped to aLogLevelas follows:LogService.LOG_ERROR-LogLevel.ERRORLogService.LOG_WARNING-LogLevel.WARNLogService.LOG_INFO-LogLevel.INFOLogService.LOG_DEBUG-LogLevel.DEBUG- Any other value -
LogLevel.TRACE
LogEntry.getLevel()must return the specified level.- Specified by:
login interfaceLogService- Parameters:
ref- TheServiceReferenceobject of the service that this message is associated with ornull.level- The severity of the message. This should be one of the defined log levels but may be any integer that is interpreted in a user defined way.message- Human readable string describing the condition ornull.- See Also:
-
log
Description copied from interface:LogServiceLogs a message with an exception associated and aServiceReferenceobject.This method will log to the
Loggernamed"LogService"for the bundle. The specified level is mapped to aLogLevelas follows:LogService.LOG_ERROR-LogLevel.ERRORLogService.LOG_WARNING-LogLevel.WARNLogService.LOG_INFO-LogLevel.INFOLogService.LOG_DEBUG-LogLevel.DEBUG- Any other value -
LogLevel.TRACE
LogEntry.getLevel()must return the specified level.- Specified by:
login interfaceLogService- Parameters:
ref- TheServiceReferenceobject of the service that this message is associated with.level- The severity of the message. This should be one of the defined log levels but may be any integer that is interpreted in a user defined way.message- Human readable string describing the condition ornull.exception- The exception that reflects the condition ornull.- See Also:
-