John Kasper Svergja
10/17/2022, 11:17 AMwithLoggingContext
). Is there considered any best practices for MDC and exceptions?
The current implementation of withLoggingContext clears all MDC fields if an exception inside the flow occurs. I would very much like the exception to contain the MDC-information.
One solution could be that withLoggingContext
provides an option to provided an exception handler. (I think it is important not to couple the exception handling to close to the framework).
Do you have any thoughts about this/what do you think? Or any suggestion on how the mdc is kept for exceptions?
For my case I think the best use of an exception handler would be to add an “meta”-exception to the original exception (addSuppressed
method ) (which is what I have done in my code, by creating a wrapper method around withLoggingContext
)Jakub Gwóźdź
10/17/2022, 12:59 PMctx: Map<String, String>
that is set with MDC.getCopyOfContextMap()
when thrown? Is this your own exception class, or existing one?John Kasper Svergja
10/18/2022, 8:21 AMaddSuppressed
I guess the exception can be provided by the libraryJohn Kasper Svergja
10/18/2022, 10:22 AMoshai
10/19/2022, 8:11 PM