slf4j icon indicating copy to clipboard operation
slf4j copied to clipboard

Introduces MDC.putAllCloseable

Open bric3 opened this issue 5 years ago • 3 comments

This feature offers the same functionality as MDC.putCloseable but for multiple values. And tries to follow the put/putAll signatures one can see on a Map. This would be extremely useful for structured logging when the appender is configured to use MDC values.

The MDCCloseable class has been modified in such a way that if a single value is used the consumed memory profile remains the same.

This change is similar to what has been done when MDC.putCloseable has been introduced 5c76844e4cd56292f46cabb3f0cfcc39f50253a2. I'm targetting branch 1.7-maintainance, but I'll be happy to port it to other branches e.g. master or 2.0 if that's necessary.

bric3 avatar Mar 12 '19 15:03 bric3

Any chances for merging this?

kr5ture avatar Jul 26 '20 21:07 kr5ture

Please merge, this is useful.

renoth avatar Mar 25 '21 08:03 renoth

For reference, I moved my code to use logstash/logstash-logback-encoder instead as it offers very good json logging in combination with the encoder's StructuredArguments typed API to preserve type in the log event json document (numbers are serialized as numbers not as String).

bric3 avatar Mar 25 '21 09:03 bric3