You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Dan Miller <di...@gmail.com> on 2013/05/09 01:06:05 UTC

Log Service

I have installed the Log bundle into felix, and have implemented the
LogListener to output those logs to the console.  I see that i can get a
reference to the bundle where the log originated, but can i get the
class/method/line number where the message was written to the log like
Log4j or the JavaLogger output in their messages?

Re: Log Service

Posted by Neil Bartlett <nj...@gmail.com>.
OSGi LogService is not really intended for debugging. It is intended
for alerting Operations about unexpected failure conditions arising in
a production system.

Most developers, given a tool like SLF4J, produce far too verbose
logging. Operations do not care about line numbers: they want to know
about network failures, unauthorised login attempts, etc. OSG
LogService is good for this because it allows great flexibility in
collecting and reporting log messages.

There is a place for both kinds of logging, and in fact many OSGi
developers do use both Log Service *and* a low-level debug logging
library like SLF4J.

Neil



On Thu, May 9, 2013 at 1:39 AM, Dan Miller <di...@gmail.com> wrote:
> thanks for the reply, Marcel!
>
> that really limits the usefulness of the osgi LogService.  why would i use
> that over slf4j, for example?
>
>
> On Wed, May 8, 2013 at 5:18 PM, Marcel Offermans <
> marcel.offermans@luminis.nl> wrote:
>
>> On May 9, 2013, at 1:06 AM, Dan Miller <di...@gmail.com> wrote:
>>
>> > I have installed the Log bundle into felix, and have implemented the
>> > LogListener to output those logs to the console.  I see that i can get a
>> > reference to the bundle where the log originated, but can i get the
>> > class/method/line number where the message was written to the log like
>> > Log4j or the JavaLogger output in their messages?
>>
>> No.
>>
>> The only thing you can get is the Exception and its stack trace, if the
>> original log call provided that.
>>
>> At best you could try writing your own implementation of LogService that,
>> when a message is logged that does not include an exception, somehow adds a
>> stack trace itself so you can later retrieve that (maybe with your own,
>> custom exception that wraps that trace).
>>
>> Greetings, Marcel
>>
>>
>> ---------------------------------------------------------------------
>> 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


Re: Log Service

Posted by Dan Miller <di...@gmail.com>.
thanks for the reply, Marcel!

that really limits the usefulness of the osgi LogService.  why would i use
that over slf4j, for example?


On Wed, May 8, 2013 at 5:18 PM, Marcel Offermans <
marcel.offermans@luminis.nl> wrote:

> On May 9, 2013, at 1:06 AM, Dan Miller <di...@gmail.com> wrote:
>
> > I have installed the Log bundle into felix, and have implemented the
> > LogListener to output those logs to the console.  I see that i can get a
> > reference to the bundle where the log originated, but can i get the
> > class/method/line number where the message was written to the log like
> > Log4j or the JavaLogger output in their messages?
>
> No.
>
> The only thing you can get is the Exception and its stack trace, if the
> original log call provided that.
>
> At best you could try writing your own implementation of LogService that,
> when a message is logged that does not include an exception, somehow adds a
> stack trace itself so you can later retrieve that (maybe with your own,
> custom exception that wraps that trace).
>
> Greetings, Marcel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Log Service

Posted by Marcel Offermans <ma...@luminis.nl>.
On May 9, 2013, at 1:06 AM, Dan Miller <di...@gmail.com> wrote:

> I have installed the Log bundle into felix, and have implemented the
> LogListener to output those logs to the console.  I see that i can get a
> reference to the bundle where the log originated, but can i get the
> class/method/line number where the message was written to the log like
> Log4j or the JavaLogger output in their messages?

No.

The only thing you can get is the Exception and its stack trace, if the original log call provided that.

At best you could try writing your own implementation of LogService that, when a message is logged that does not include an exception, somehow adds a stack trace itself so you can later retrieve that (maybe with your own, custom exception that wraps that trace).

Greetings, Marcel


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