According to this article https://www.codebyamir.com/blog/testing-log-statements-in-spring-boot, it's possible to assert log4j logging statements with springs OutputCaptureExtension. Is that correct? Because the following test fails:

public class LogServiceTest {
    private final Logger logger = LoggerFactory.getLogger(LogServiceTest.class);

    @Test
    @ExtendWith(OutputCaptureExtension.class)
    public void test(CapturedOutput capture) {
        logger.info("junit");
           assertEquals("junit", capture.getAll());
    }
}

If that's not supported, maybe this issue could serve for an extension proposal to support log4j?

Comment From: wilkinsona

Without a sample, it's hard to be certain, but I suspect this is a duplicate of https://github.com/spring-projects/spring-boot/issues/27902. If that's not the case, please provide a complete yet minimal sample that reproduces the problem and we can take another look.

Comment From: membersound

Indeed adding follow="true" fixes the problem.