Hello everyone.
This may be a silly question but regardless, I would appreciate
feedback. I am setting up an OSGi environment for our embedded device; a
number of internal services will be run inside the OSGI environment and
it will also serve as the main mechanism for third parties to add
applications/services.
The requirements that I have in mind are the following:
(a) Provide an easy and uniform way for bundle writers to log their
messages/exceptions,... (as in LogService from OSGi) in this environment
(b) Each log coming from an application/library/service should report
the origin
To that end, I am planning on using one of the LogService/LogReader
Service implementations (from Felix or Equinox, for example) and add a
generic bundle and register that as a LogListener. My LogListener will
use one of the common backends to log the messages (such as log4j or
even the default JDK Log API). Once this is done, all applications and
services can use the OSGi log service to log whatever is needed and I
have one place that I can go to manage how I want the logs to be
printed, where to be placed, etc.
This satisfies (a). As for (b), I like to use the
LogService.log(ServiceReference,....) and in my LogListener, I grab the
source from logEntry.getBundle().getSymbolicName() to instantiate or get
a hold of a (backend) logger.
Questions:
1. Is this a/the right approach to this generic problem? If not, could
someone point me to a better solution?
2. For someone who is writing a bundle for this environment, how should
he/she go about providing the ServiceReference that is required for the
above log signature in their code?
Many thanks
Ali.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]