-
Notifications
You must be signed in to change notification settings - Fork 40.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log4j2 not working with Spring Boot 3.4.2 together with BlockHound #43963
Comments
Thanks for the report and for the minimal sample. I assume that something has changed in Spring Boot 3.4.2 that is causing BlockHound to break Log4j2 in some way. Unfortunately, given that this works fine without BlockHound and the way in which BlockHound works, I don't think there's anything we can do about this in Spring Boot. Please raise a BlockHound issue so that they can investigate further. |
Re-opening. Thanks to @violetagg's analysis, this has been tracked down to an assumption in |
Thanks for the sample, @micopiira.
One of the options is to revert b6b9237 and fix Meanwhile, you can use this solution reactor/BlockHound#469 (comment) |
@nosan Please check the screenshot below -> it is not the delegator that closes but the real system stream ![]()
|
Oh, you're right, my mistake. // stream = original System.out
// System.out = BlockHound.PrintStreamDelegate
private static void closeNonSystemStream(final OutputStream stream) {
// Close only non-system streams
if (stream != System.out && stream != System.err) {
try {
stream.close();
} catch (IOException error) {
// We are at the lowest level of the system.
// Hence, there is nothing better we can do but dumping the failure.
error.printStackTrace(System.err);
}
}
} so Log42J closes the original stream. |
I noticed a similar problem in IntelliJ: When I upgraded to 3.4.2 and executed a SpringBootTest with OutputCaptureExtension (Log Framework Log4J) the test is marked as "Not started" after some time and produces no log output. However when the tests are run via maven it works fine. When I downgraded again to 3.4.1 the behavior is back to normal. Can anybody else validate this? |
I've tried the following test with IntelliJ IDEA and 3.4.2: @SpringBootTest
@ExtendWith(OutputCaptureExtension.class)
class SpringBootLog4j2DemoApplicationTests {
@Test
void contextLoads(CapturedOutput output) {
Assertions.assertThat(output).isNotEmpty();
}
} And indeed it does not work for me as well. ![]() This fix main...nosan:spring-boot:gh-43963 resolves both issues. |
Thanks for validating ;) Are you able to get this into 3.4.3? |
I don't make the decision, but it seems likely that the plan is to fix it in 3.4.3. The solution I proposed is just one option—another option is to revert |
When upgrading to Spring Boot 3.4.2 our logging stopped completely working.
After narrowing down I figured the problem happens with Spring Boot 3.4.2 when using Log4j2 together with BlockHound.
Here is a minimum reproducer repo: https://github.com/micopiira/spring-boot-log4j2-issue
Spring Boot 3.4.1 with exact same Log4j2 version and BlockHound version works.
Spring Boot 3.4.1:
Spring Boot 3.4.2:
The text was updated successfully, but these errors were encountered: