You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Ali Naddaf <al...@naddaf.org> on 2009/09/16 17:07:47 UTC

Question on logging in an OSGi environment (best practices)

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: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Question on logging in an OSGi environment (best practices)

Posted by Leen Toelen <to...@gmail.com>.
Hi,

have you looked at Pax Logging
http://wiki.ops4j.org/display/paxlogging/Pax+Logging? It builds on
Log4J, and can use almost all common logging api's. Configuration is
very easy when you use it with fileinstall and the config admin
service.

Leen

On Wed, Sep 16, 2009 at 5:07 PM, Ali Naddaf <al...@naddaf.org> wrote:
> 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: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org