diff --git a/src/main/java/de/dm/prom/structuredlogging/MdcContext.java b/src/main/java/de/dm/prom/structuredlogging/MdcContext.java index 90f5a0f..489784a 100644 --- a/src/main/java/de/dm/prom/structuredlogging/MdcContext.java +++ b/src/main/java/de/dm/prom/structuredlogging/MdcContext.java @@ -8,6 +8,7 @@ import org.slf4j.MDC; import java.lang.reflect.InvocationTargetException; +import java.time.Duration; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; @@ -40,6 +41,7 @@ public final class MdcContext implements java.io.Closeable { module.addSerializer(Period.class, new ToStringSerializer()); module.addSerializer(ZonedDateTime.class, new ToStringSerializer()); module.addSerializer(LocalTime.class, new ToStringSerializer()); + module.addSerializer(Duration.class, new ToStringSerializer()); OBJECT_MAPPER.registerModule(module); } diff --git a/src/test/java/de/dm/prom/structuredlogging/SpringMdcTaskDecoratorUnitTest.java b/src/test/java/de/dm/prom/structuredlogging/SpringMdcTaskDecoratorUnitTest.java index e100e8b..e2217bc 100644 --- a/src/test/java/de/dm/prom/structuredlogging/SpringMdcTaskDecoratorUnitTest.java +++ b/src/test/java/de/dm/prom/structuredlogging/SpringMdcTaskDecoratorUnitTest.java @@ -188,7 +188,7 @@ void logOverwriteLogsNothingWhenEmpty() throws Throwable { @Test @DisplayName("decorate decorates and does not log WARN when encountering thread without existing MDC context with JUST_OVERWRITE") - void logOverweiteDoesNotLog() throws Throwable { + void logOverwriteDoesNotLog() throws Throwable { SpringMdcTaskDecorator mdcTaskDecorator = new SpringMdcTaskDecorator(OverwriteStrategy.JUST_OVERWRITE); MDC.put("testKey", "testValue");