Well, after some experiments with the MDC method, I found out that my
custom property is set only in log messages coming from specific threads
and not globally, which is what I’m after…
This seems to be due to different ThreadPools running, as noted in the logback
MDC documentation <http://logback.qos.ch/manual/mdc.html>.
I then tried setting the system property karaf.name inside one of my
bundles to the desired dynamic value and it seems to work ok as of now for
the current need of a global ID.
​

2016-10-04 9:54 GMT+02:00 Alan Alberghini <[email protected]>:

> Thanks for the advice, JB.
>
> In the end, I just added this instruction to add the property to the MDC:
>
> MDC.put("customProp", "AAAAAAA");
>
> While searching for solutions, I also found someone’s advice to change the
> ${karaf.name} property from root to the desired value, so that too would
> be forwarded via decanter to the appenders. May I ask you if there’s a way
> to do it programmatically from inside a bundle?
>
> On 30/09/2016 09:59, jbonofre [via Karaf] wrote:
>
> I meant that:
>
> 1. If you add key=value in
> etc/org.apache.karaf.decanter.collector.log.cfg file, it will be added
> to the event. So you can provide those custom properties using
> ConfigAdmin (on the org.apache.karaf.decanter.collector.log pid), but it
> will trigger a restart of the collector as the configuration will change.
>
> 2. IMHO, MDC for dynamic property is probably the best way to go.
>
> Regards
> JB
>
> On 09/30/2016 09:48 AM, 414n wrote:
>
> > Hi JB,
> >
> > thanks for the reply.
> > I'm not sure I understood correctly, but do you mean that the code I
> posted
> > would be good for setting the custom property I'd like to set? Because,
> for
> > what I saw, it did nothing and Decanter never added the custom property
> to
> > the collected logs...
> >
> >
> >
> >
> > --
> > View this message in context: http://karaf.922171.n3.nabble.
> com/Decanter-log-appender-properties-tp4048206p4048210.html
> > Sent from the Karaf - User mailing list archive at Nabble.com.
> >
>
> --
> Jean-Baptiste Onofré
> [hidden email] <http:///user/SendEmail.jtp?type=node&node=4048212&i=0>
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://karaf.922171.n3.nabble.com/Decanter-log-appender-
> properties-tp4048206p4048212.html
> To unsubscribe from Decanter log appender properties, click here
> <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4048206&code=YWxhbkBpb29vdGEuY29tfDQwNDgyMDZ8NjExMjcwNjA2>
> .
> NAML
> <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
> ​
>




--
View this message in context: 
http://karaf.922171.n3.nabble.com/Decanter-log-appender-properties-tp4048206p4048249.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to