[slf4j-dev] Contributing MDC-aware Executors to slf4j

Ceki ceki at qos.ch
Sat Apr 11 13:16:56 CEST 2020


Hi Robert,

Thank you for your post.

My feeling is that while the calls MDC are usually simple, said 
invocations need to be correctly embedded within the environment of the 
asynchronous programming model in use. I have also observed that there 
is a strong tendency by developers to forget to clear the MDC. There is 
also a tendency to sprinkle the code with MDC.clear() all over the place 
which is almost just as bad.


Anyway, I'd happy to collaborate.

--
Ceki Gülcü

On 09.04.2020 14:01, Robert Munteanu wrote:
> Hi,
> 
> When working with asynchronous programming models ( Netty,
> CompletableFuture, OSGi Promises ) it becomes problematic to propagate
> the MDC between the worker threads.
> 
> I see such questions asked and solutions that work more or less posted,
> e.g. [1], [2], [3].
> 
> I think it would be worthwhile to provide basic utilities in the slf4j
> project, otherwise everyone keeps reinventing the wheel.
> 
> I have a couple of classes ( Executor, ScheduledExecutorService ) that
> work well with my setup (Netty, OSGi Promises ) and would be willing to
> contribute them to slf4j.
> 
> Is there interest in accepting such a contribution?
> 
> Thanks,
> Robert
> 
> [1]: https://stackoverflow.com/questions/28668560/using-org-slf4j-mdc-with-netty-channels
> [2]: https://stackoverflow.com/questions/49110745/how-to-retain-slf4j-mdc-logging-context-in-completablefuture
> [3]: https://medium.com/asyncparadigm/logging-in-a-multithreaded-environment-and-with-completablefuture-construct-using-mdc-1c34c691cef0
> 

> 


More information about the slf4j-dev mailing list