<div dir="ltr">Generally, what you're describing isn't necessarily the MDC. It sounds more like distributed tracing:<div><br></div><div><a href="http://opentracing.io/">http://opentracing.io/</a><br></div><div><a href="http://zipkin.io/">http://zipkin.io/</a><br></div><div><br></div><div>The MDC/ThreadContext APIs are useful for maintaining contextual data within threads, but if you want to propagate between microservices or do any sort of correlation, you'll need to standardize ways on passing that context data over HTTP, JMS, etc. A couple projects exist out there that can instrument your IPC with the relevant ids and will send log messages to a Zipkin collector (or similar):</div><div><br></div><div><a href="https://github.com/openzipkin/brave">https://github.com/openzipkin/brave</a></div><div><a href="https://cloud.spring.io/spring-cloud-sleuth/">https://cloud.spring.io/spring-cloud-sleuth/</a><br></div><div><br></div><div>If this is what you're working on, then I hope this helps! I'm working on a very similar project at my work right now, so this is all fresh.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 25 February 2017 at 14:40, Shanholtz, Jeff <span dir="ltr"><<a href="mailto:jeff.shanholtz@intel.com" target="_blank">jeff.shanholtz@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for the quick responses everyone! Now I know what to start researching. :)<br>
<div class="HOEnZb"><div class="h5"><br>
-----Original Message-----<br>
From: slf4j-user [mailto:<a href="mailto:slf4j-user-bounces@qos.ch">slf4j-user-bounces@<wbr>qos.ch</a>] On Behalf Of Ceki Gülcü<br>
Sent: Saturday, February 25, 2017 12:37 PM<br>
To: User list for the slf4j project <<a href="mailto:slf4j-user@qos.ch">slf4j-user@qos.ch</a>><br>
Subject: Re: [slf4j-user] logging common data simply<br>
<br>
<br>
Regarding wrong line numbers shown with your log wrapper, with logback you can fix the issue by calling:<br>
<br>
LoggerContext lc = (LoggerContext) LoggerFactory.<wbr>getILoggerFactory();<br>
lc.getFrameworkPackages().add(<wbr>"package of log wrapper");<br>
<br>
Best regards,<br>
<br>
--<br>
Ceki<br>
<br>
On 2/25/2017 21:15, Joachim Durchholz wrote:<br>
> On <a href="tel:25.02.2017%2020" value="+12502201720">25.02.2017 20</a>:34, Shanholtz, Jeff wrote:<br>
>> I have a scenario where I have 1, 2, or 3 pieces of data (guids)<br>
>> which I want to to log with all messages in order to track records as<br>
>> they traverse their way through a series of microservices.<br>
><br>
> That's a common scenario.<br>
><br>
>> Currently I’ve written my own wrapper class with my own debug, info,<br>
>> warn, error methods that take these 3 parameters, followed by the<br>
>> message field, followed by the optional parameters.<br>
><br>
> Any library function that you call will still use the original loggers<br>
> so you won't know with which of the guids some log message from deep<br>
> inside a call is associated.<br>
> This is a real PITA if you have multiple requests executing in parallel.<br>
><br>
>> There must be a better way, plus this has the disadvantage of<br>
>> rendering the line number useless in log messages because the line<br>
>> numbers are the line numbers from my log wrapper class, not the<br>
>> actual code doing the logging.<br>
><br>
> Elliot has the start of the trail right: Use an MDC.<br>
> The other half of the trail is that formatters have an escape code for<br>
> extracting data from the MDC (%m if I remember correctly).<br>
><br>
> HTH<br>
> Jo<br>
______________________________<wbr>_________________<br>
slf4j-user mailing list<br>
<a href="mailto:slf4j-user@qos.ch">slf4j-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/slf4j-user" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/<wbr>listinfo/slf4j-user</a><br>
______________________________<wbr>_________________<br>
slf4j-user mailing list<br>
<a href="mailto:slf4j-user@qos.ch">slf4j-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/slf4j-user" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/<wbr>listinfo/slf4j-user</a></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Matt Sicker <<a href="mailto:boards@gmail.com" target="_blank">boards@gmail.com</a>></div>
</div>