Description
Description
This issue is captured in spring-projects/spring-boot#33450. During shutdown properties are being accessed, which causes the Spring Property Source to be invoked. However, it needs an active LoggerContext to work.
Configuration
Version: 2.20.0
Logs
[Stacktraces, errors, etc. relevant applications logs.]
Reproduction
While building a sample Spring Boot app I ran into a similar, but related, error.
WARN StatusConsoleListener Unable to register Log4j shutdown hook because JVM is shutting down. Using SimpleLogger
Exception in thread "SpringApplicationShutdownHook" java.lang.ClassCastException: class org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to class org.apache.logging.log4j.core.LoggerContext (org.apache.logging.log4j.simple.SimpleLoggerContext and org.apache.logging.log4j.core.LoggerContext are in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @5b480cf9)
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.getLoggerContext(Log4J2LoggingSystem.java:480)
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.lambda$getShutdownHandler$2(Log4J2LoggingSystem.java:452)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.SpringApplicationShutdownHook.run(SpringApplicationShutdownHook.java:110)
at java.base/java.lang.Thread.run(Thread.java:833)
We have seen this in other cases but have never come up with a permanent solution.