-
Notifications
You must be signed in to change notification settings - Fork 97
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
BlockHound completely breaks Log4j2 with Spring Boot 3.4.2 #469
Comments
@micopiira We will check the issue |
@micopiira I think your analysis are correct. I think the issue is in |
Yes that is exactly what happens. This issue can be avoided by calling @SpringBootApplication
public class SpringBootLog4j2DemoApplication {
static {
BlockHound.install();
}
private static final Logger logger = LogManager.getLogger(SpringBootLog4j2DemoApplication.class);
public static void main(String[] args) {
SpringApplication.run(SpringBootLog4j2DemoApplication.class, args);
}
@Bean
ApplicationRunner init() {
return args -> logger.info("Hello World!");
}
} But as I said, this worked fine with Spring Boot 3.4.1, so I'm not sure if there is anything to "fix" and who/where this should be fixed? |
IMO this is not BlockHound issue and the real issue is the assumption in |
Expected Behavior
Log4j2 should work with Spring Boot 3.4.2 + BlockHound
Actual Behavior
After upgrading to Spring Boot 3.4.2, we noticed that Log4j2 completely stopped working. After narrowing down on possible causes, it seems that using BlockHound together with Spring Boot 3.4.2 causes this. Spring Boot 3.4.1 works fine with exact same Log4j2 and BlockHound version.
I initially reported this issue to Spring Boot GitHub repo here: spring-projects/spring-boot#43963 but I was instructed to report this issue here since they don't think they can do anything about this in Spring Boot.
I'm quite certain that this commit: spring-projects/spring-boot@b6b9237 is the culprit here. BlockHound
StandardOutputIntegration
changes theSystem.out
stream, which causes theStatusConsoleListener#setStream
call inLog4J2LoggingSystem
to callcloseNonSystemStream
on thePrintStreamDelegate
causing logging to console to not work. Not sure if this should be fixed in Spring boot, BlockHound or Log4j2.Steps to Reproduce
Your Environment
netty
, ...): Spring Boot 3.4.2java -version
): Eclipse Temurin 21.0.4uname -a
): Darwin Micos-MacBook-Pro.local 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec 6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000 arm64The text was updated successfully, but these errors were encountered: