I can understand how the stack-based mdc might be convenient and useful, but I 
don't think it fits my use-cases. That said, I wonder if the API could be 
improved in such a way that it could leverage the application stack instead of 
maintaining its own -- this is an issue that I've encountered in tracing 
implementations as well, where asymmetric interactions to cause the application 
stack and internal stack to get out of sync. Perhaps using something like 
putCloseable[1] would allow the data needed to reset to be stored in the 
closeable without maintaining a standalone stack (at the cost of the ability to 
support getCopyOfDequeByKey[2]).

I think there's a bug in the proposed PR where MDC consumers cannot distinguish 
between MDC.put values meant to take advantage of the string format and 
correctly-formatted MDC.pushByKey. I think we need agreement between put/push 
and get/pop.

-ck

1. 
https://www.slf4j.org/api/org/slf4j/MDC.html#putCloseable-java.lang.String-java.lang.String-
2. 
https://www.slf4j.org/api/org/slf4j/MDC.html#getCopyOfDequeByKey-java.lang.String-

On Fri, Apr 15, 2022, at 16:27, Piotr P. Karwasz wrote:
> Hello everybody,
> 
> In SLF4J-531 <https://jira.qos.ch/browse/SLF4J-531> Ceki added support for
> an MDC containing stack values in SLF4J 2.0. Since some servlet containers
> like Jetty are already distributing alpha versions of SLF4J 2.0, I started
> implementing the new SLF4J 2.0 in the `slf4j-2.0` branch of the repository.
> 
> Personally I am not convinced that introducing a second stack valued MDC
> has many applications and I believe that Ralph shares my opinion. Therefore
> I would propose to implement it using the currently available MDC (cf. PR
> #820 <https://github.com/apache/logging-log4j2/pull/820>). What do you
> think about it?
> 
> Another idea might be to extend the current MDC to allow object values.
> That is what is already available in JBoss Log Manager.
> 
> Piotr

Reply via email to