Skip to content

CapturedOutput is empty when using Log4J2 StatusLogger  #43578

@nosan

Description

@nosan

While working on #43575 I noticed that Log4j2 Smoke Tests does not contain a test to verify that DefaultErrorHandler prints an error into the console if StructuredLogLayout throws an Exception.

I added a test to check DefaultErrorHandler prints errors but unfortunately, it did not work since Log42J StatusLogger keeps the reference to the outdated PrintStreamCapture.

Reproducer: main...nosan:spring-boot:log4j2-status-logger

If you run a single test shouldCaptureCustomizerError in SampleLog4j2StructuredLoggingApplicationTests everything will be fine, but if you run all tests in SampleLog4j2StructuredLoggingApplicationTests, the CapturedOutput will be empty and shouldCaptureCustomizerError test will fail.

Possible fix main...nosan:spring-boot:log4j2-status-logger-fix but I am not sure this is the right way.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions