SLF4J / SLF4J-557 [In Progress] MDCCloseable: not a great fit for a try-with-resources statement
============================== Here's what changed in this issue in the last few minutes. There is 1 comment. View or comment on issue using this link https://jira.qos.ch/browse/SLF4J-557 ============================== 1 comment ------------------------------ Alberto Scotto on 23/Mar/23 13:28 To make things more clear. Given the following test: {code:java} @Test public void test() { try (MDC.MDCCloseable ignored = MDC.putCloseable("k", "val")) { log.info("BEGIN try"); throw new RuntimeException(); } catch (Exception e) { log.error("FAILED try", e); // MDC will not be attached to this log at runtime! } }{code} Actual logs produced: {noformat} 2023-03-23 13:21:37,535 INFO MyTest k=val - BEGIN try 2023-03-23 13:21:37,537 ERROR MyTest k= - FAILED try {noformat} Expected: {noformat} 2023-03-23 13:21:37,535 INFO MyTest k=val - BEGIN try 2023-03-23 13:21:37,537 ERROR MyTest k=val - FAILED try{noformat} ============================== This message was sent by Atlassian Jira (v9.6.0#960000-sha1:a3ee8af) _______________________________________________ slf4j-dev mailing list slf4j-dev@qos.ch https://mailman.qos.ch/cgi-bin/mailman/listinfo/slf4j-dev