diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCaptureExtension.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCaptureExtension.java index 6d08448dea15..3a6528bcddbd 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCaptureExtension.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCaptureExtension.java @@ -56,6 +56,30 @@ * } * * } + * + *
+ * To ensure that their output can be captured, Java Util Logging (JUL) and Log4j2 require + * additional configuration. + *
+ * To reliably capture output from Java Util Logging, reset its configuration after each + * test: + * + *
+ * @AfterEach + * void reset() throws Exception { + * LogManager.getLogManager().readConfiguration(); + * } + *+ *
+ * To reliably capture output from Log4j2, set the follow
attribute of the
+ * console appender to true
:
+ *
+ *
+ * <Appenders> + * <Console name="Console" target="SYSTEM_OUT" follow="true"> + * ... + * </Console> +* </Appenders> ** * @author Madhura Bhave