You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Hilderich <hi...@yahoo.de> on 2013/08/29 11:37:29 UTC

Logging into the bundle log file via to("log:...")

Hello All!

We are using Apache Camel 2.10.4 within Apache Karaf 2.3.1. 

We have a Camel Route and there is a logging endpoint inside:

The logging in Apache Karaf is configured in a way that every bundle
produces its
own logfile and that Camel Route also resides in such a bundle:

My intention is to get the logging message produced inside the Camel Route
into the 
bundle log file. At the moment I can find that logging message only in
/karaf.log/ and in /org.apache.camel.camel-core.log/

What logging name or logging category has to be use or what changes in pax
logging 
configuration are essential to achieve this?

Cheers and thanks in advance
Hilderich







--
View this message in context: http://camel.465427.n5.nabble.com/Logging-into-the-bundle-log-file-via-to-log-tp5738205.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Logging into the bundle log file via to("log:...")

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Hello

I did some investigation and I think it's almost impossible to properly set
the bundle in org.ops4j.pax.logging.slf4j.Slf4jLogger which is used by
CamelLogger.

The problem is described  here
<https://issues.apache.org/jira/browse/CAMEL-6694?focusedCommentId=13955364&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13955364> 
. org.ops4j.pax.logging.internal.BundleHelper always finds the camel-core
bundle as the one which requests creating Logger.

So either we introduce a way of configuring
org.ops4j.pax.logging.internal.BundleHelper (by setting a filter or number
of traces in stacktrace) or we could just use user provided (in message
headers) Logger instance and use it in
org.apache.camel.processor.CamelLogProcessor.process(**) methods.

We could use org.apache.camel.util.CamelLogger.log() methods which take
Logger parameter (if appropriate object is found in headers.

What do you think?
regards
Grzegorz Grzybek



--
View this message in context: http://camel.465427.n5.nabble.com/Logging-into-the-bundle-log-file-via-to-log-tp5738205p5749575.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Logging into the bundle log file via to("log:...")

Posted by Raul Kripalani <ra...@evosent.com>.
Great idea. I logged a ticket:
https://issues.apache.org/jira/browse/CAMEL-6694.

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Sun, Sep 1, 2013 at 9:39 AM, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> Yeah wonder if we could improve this in Camel, so .to("log:xxx") and
> .log("foo") uses a logger created by the application bundle.
>
> So if we let the application bundles classloader try to load the
> logger as a class, and use that? Well we could try to experiment. Then
> by default it still runs normally for end users, but for ppl using
> that shift appender then the pax-logger framework may be able to
> figure out the logger class is from the application bundle, and not
> from camel-core bundle.
>
>
>
>
>
> On Fri, Aug 30, 2013 at 5:03 PM, Raul Kripalani <ra...@evosent.com> wrote:
> > If you use the logging API directly (e.g. slf4j) from within a Processor,
> > it should. But that's not the Camel way of doing things ;-)
> >
> > *Raúl Kripalani*
> > Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
> > Integration specialist
> > http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
> > http://blog.raulkr.net | twitter: @raulvk
> >
> > On Fri, Aug 30, 2013 at 3:58 PM, Hilderich <hi...@yahoo.de>
> wrote:
> >
> >> Hello Raul,
> >>
> >> as you can see below I am using the bundle name as the sifting key:
> >>
> >> As you have mentioned I have no hope that plain logging inside the route
> >> can
> >> appear in
> >> the proper bundle log file, isn't it?
> >>
> >>
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://camel.465427.n5.nabble.com/Logging-into-the-bundle-log-file-via-to-log-tp5738205p5738319.html
> >> Sent from the Camel - Users mailing list archive at Nabble.com.
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Re: Logging into the bundle log file via to("log:...")

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah wonder if we could improve this in Camel, so .to("log:xxx") and
.log("foo") uses a logger created by the application bundle.

So if we let the application bundles classloader try to load the
logger as a class, and use that? Well we could try to experiment. Then
by default it still runs normally for end users, but for ppl using
that shift appender then the pax-logger framework may be able to
figure out the logger class is from the application bundle, and not
from camel-core bundle.





On Fri, Aug 30, 2013 at 5:03 PM, Raul Kripalani <ra...@evosent.com> wrote:
> If you use the logging API directly (e.g. slf4j) from within a Processor,
> it should. But that's not the Camel way of doing things ;-)
>
> *Raúl Kripalani*
> Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
> Integration specialist
> http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
> http://blog.raulkr.net | twitter: @raulvk
>
> On Fri, Aug 30, 2013 at 3:58 PM, Hilderich <hi...@yahoo.de> wrote:
>
>> Hello Raul,
>>
>> as you can see below I am using the bundle name as the sifting key:
>>
>> As you have mentioned I have no hope that plain logging inside the route
>> can
>> appear in
>> the proper bundle log file, isn't it?
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Logging-into-the-bundle-log-file-via-to-log-tp5738205p5738319.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Logging into the bundle log file via to("log:...")

Posted by Raul Kripalani <ra...@evosent.com>.
If you use the logging API directly (e.g. slf4j) from within a Processor,
it should. But that's not the Camel way of doing things ;-)

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Fri, Aug 30, 2013 at 3:58 PM, Hilderich <hi...@yahoo.de> wrote:

> Hello Raul,
>
> as you can see below I am using the bundle name as the sifting key:
>
> As you have mentioned I have no hope that plain logging inside the route
> can
> appear in
> the proper bundle log file, isn't it?
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Logging-into-the-bundle-log-file-via-to-log-tp5738205p5738319.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Logging into the bundle log file via to("log:...")

Posted by Hilderich <hi...@yahoo.de>.
Hello Raul,

as you can see below I am using the bundle name as the sifting key:

As you have mentioned I have no hope that plain logging inside the route can
appear in
the proper bundle log file, isn't it?





--
View this message in context: http://camel.465427.n5.nabble.com/Logging-into-the-bundle-log-file-via-to-log-tp5738205p5738319.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Logging into the bundle log file via to("log:...")

Posted by Raul Kripalani <ra...@evosent.com>.
Just to clarify: I think you should set appropriate contextIds for your
Camel Contexts, and sift your logs based on the "camel.contextId" key in
the MDC, not the camelContextId key as the post suggests (as we changed the
key from 2.10 onwards).

Otherwise, if you use the bundle ID as the sifting key, all your logs from
all contexts may end up in the log file for the camel-core bundle, as the
log statement is ultimately produced there (I haven't tested this – just
speaking off the top of my head).

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Thu, Aug 29, 2013 at 2:54 PM, Raul Kripalani <ra...@evosent.com> wrote:

> Hi Hilderich,
>
> Are you using the MDCSiftAppender? What key are you sifting on?
>
> Perhaps this post will help you:
> http://dywicki.pl/2012/02/advanced-apache-camel-logging-and-best-practices/
> .
>
> Regards,
>
> *Raúl Kripalani*
> Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
> Integration specialist
> http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
> http://blog.raulkr.net | twitter: @raulvk
>
> On Thu, Aug 29, 2013 at 10:37 AM, Hilderich <hi...@yahoo.de> wrote:
>
>> Hello All!
>>
>> We are using Apache Camel 2.10.4 within Apache Karaf 2.3.1.
>>
>> We have a Camel Route and there is a logging endpoint inside:
>>
>> The logging in Apache Karaf is configured in a way that every bundle
>> produces its
>> own logfile and that Camel Route also resides in such a bundle:
>>
>> My intention is to get the logging message produced inside the Camel Route
>> into the
>> bundle log file. At the moment I can find that logging message only in
>> /karaf.log/ and in /org.apache.camel.camel-core.log/
>>
>> What logging name or logging category has to be use or what changes in pax
>> logging
>> configuration are essential to achieve this?
>>
>> Cheers and thanks in advance
>> Hilderich
>>
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Logging-into-the-bundle-log-file-via-to-log-tp5738205.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>

Re: Logging into the bundle log file via to("log:...")

Posted by Raul Kripalani <ra...@evosent.com>.
Hi Hilderich,

Are you using the MDCSiftAppender? What key are you sifting on?

Perhaps this post will help you:
http://dywicki.pl/2012/02/advanced-apache-camel-logging-and-best-practices/.

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Thu, Aug 29, 2013 at 10:37 AM, Hilderich <hi...@yahoo.de> wrote:

> Hello All!
>
> We are using Apache Camel 2.10.4 within Apache Karaf 2.3.1.
>
> We have a Camel Route and there is a logging endpoint inside:
>
> The logging in Apache Karaf is configured in a way that every bundle
> produces its
> own logfile and that Camel Route also resides in such a bundle:
>
> My intention is to get the logging message produced inside the Camel Route
> into the
> bundle log file. At the moment I can find that logging message only in
> /karaf.log/ and in /org.apache.camel.camel-core.log/
>
> What logging name or logging category has to be use or what changes in pax
> logging
> configuration are essential to achieve this?
>
> Cheers and thanks in advance
> Hilderich
>
>
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Logging-into-the-bundle-log-file-via-to-log-tp5738205.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Logging into the bundle log file via to("log:...")

Posted by pradeep <pr...@gmail.com>.
Hi, 

The below mentioned link will be use full for you.
http://servicemix.396122.n5.nabble.com/OSGI-Bundle-log4j-td421030.html 

In you osgi application do you have log4j.xml file?



--
View this message in context: http://camel.465427.n5.nabble.com/Logging-into-the-bundle-log-file-via-to-log-tp5738205p5738219.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Logging into the bundle log file via to("log:...")

Posted by Hilderich <hi...@yahoo.de>.
There is a workaround in order to use the bundle log file. You can reach this
by using a Camel Processor 
and from there use the logger from the class that contains the route
definition:



The endpoint to("log:...") is part of Apache Camel and therefore the log
message doesn't reach
the bundle log file but instead log file /org.apache.camel.camel-core.log/. 
The question remains what logger/loggingCategory you have to use inside the
log component. Any ideas?




--
View this message in context: http://camel.465427.n5.nabble.com/Logging-into-the-bundle-log-file-via-to-log-tp5738205p5738214.html
Sent from the Camel - Users mailing list archive at Nabble.com.