Files
spring-boot/core
Piotr P. Karwasz 7d34320401 Simplify Log4J2LoggingSystem
Streamline and harden `Log4J2LoggingSystem` by delegating more
functionality. The commit makes updates in two key areas:

Previously, each method fetched the `LoggerContext` directly from
`LogManager` and cast it to `....core.LoggerContext`. This approach
has several issues:

* ClassCastException risks:
  - When Log4j Core is on the classpath but not the active implementation
    (e.g. when `log4j-to-slf4j` is used).
  - During shutdown, when `LogManager` may return a `SimpleLoggerContext`
    (see spring-projects/spring-boot#26953).

* Unexpected reinitialization:
  - If the logger context had already been stopped, `Log4J2LoggingSystem`
    would trigger creation of a new context, even mid-shutdown.

Configuration file detection was previously hardcoded in
`Log4J2LoggingSystem`, which limited flexibility:

* Harder to support additional configuration formats.

* Coupled Spring Boot to internal Log4j Core classes such as
  `AuthorizationProvider`.

This change now delegates configuration resolution to Log4j. This reduces
reliance on internal APIs and allows Log4j Core to handle configuration
formats and factories more naturally.

Signed-off-by: Piotr P. Karwasz <piotr@github.copernik.eu>

See gh-47424
2025-10-22 23:41:11 -07:00
..
2025-10-22 23:41:11 -07:00
2025-10-21 11:30:56 -07:00