You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Thanks, @philwebb.
I am worried about what happens if someone replaces fallbackListener with their own PrintStream. In that scenario, Log4J2LoggingSystem would overwrite it with System.out.
Maybe reset fallbackListener's stream should be applied only in the smoke-test.
I did a bit of manual testing for that and I think Log4J2LoggingSystem sets the stream before the configuration is applied. In other words, I think it sets the stream to System.out and then the user configuration kicks in and changes it to whatever they want.
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 ifStructuredLogLayout
throws an Exception.I added a test to check
DefaultErrorHandler
prints errors but unfortunately, it did not work since Log42JStatusLogger
keeps the reference to the outdatedPrintStreamCapture
.Reproducer: main...nosan:spring-boot:log4j2-status-logger
If you run a single test
shouldCaptureCustomizerError
inSampleLog4j2StructuredLoggingApplicationTests
everything will be fine, but if you run all tests inSampleLog4j2StructuredLoggingApplicationTests
, theCapturedOutput
will be empty andshouldCaptureCustomizerError
test will fail.Possible fix main...nosan:spring-boot:log4j2-status-logger-fix but I am not sure this is the right way.
The text was updated successfully, but these errors were encountered: