OutputCaptureExtension does not capture console log, It would be nice if spring boot could provide ConsoleLogCaptureExtension and CapturedConsoleLog.
Comment From: wilkinsona
Output capture should capture everything written to System.out and System.err, including logging using a console appender. We have a few tests of our own that verify that the expected logging is produced which rely on this behaviour. If this isn't working for you, please provide a minimal example of the behaviour that you're seeing, and we can take another look.
Comment From: quaff
Here is my minimal example example.zip
1. I'm using log4j2, use default logback will not cause failure.
2. I'm using both @ExtendWith(SpringExtension.class) and @ExtendWith(OutputCaptureExtension.class), It looks like SpringExtension activated before OutputCaptureExtension causing capture failure.
Comment From: philwebb
You need to set follow="true" on your console append as we do with the default config.
<Appenders>
<Console name="CONSOLE" target="SYSTEM_OUT" follow="true">
<PatternLayout
pattern="%style{%d %25.25t %60.60c{1.}}{cyan} %highlight{%p %m}%n%throwable" />
</Console>
</Appenders>
Comment From: quaff
You need to set
follow="true"on your console append as we do with the default config.
<Appenders> <Console name="CONSOLE" target="SYSTEM_OUT" follow="true"> <PatternLayout pattern="%style{%d %25.25t %60.60c{1.}}{cyan} %highlight{%p %m}%n%throwable" /> </Console> </Appenders>
It works, thanks very much.
Comment From: emeraldhieu
Adding follow="true" doesn't work for me in Spring Boot 3.x. I've copied the whole file https://github.com/spring-projects/spring-boot/blob/bb11abef2c00d59e2b86a03f30efd530c3f4a618/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2.xml#L11
Comment From: wilkinsona
@emeraldhieu Please open a new issue with a complete yet minimal example and we can take a look.