Closed
Description
Description
In a Spring Boot application Log4j Core is initialized at least twice:
- the first initialization is the static Log4j Core initialization (Spring's
Environment
is not available yet), - the second initialization is performed programmatically by Spring Boot as soon as it creates an
Environment
. It can use the same configuration file as the first one.
On the other hand the builder of SpringProfileArbiter
returns null
if no Spring Environment
is present, which causes (handled) NullPointerException
s in AbstractConfiguration#processConditionals
or AbstractConfiguration#processSelect
.
Since the arbiter logic itself accepts a null
environment, we should remove the following null-check:
environment = (Environment) loggerContext.getObject(Log4j2SpringBootLoggingSystem.ENVIRONMENT_KEY);
if (environment == null) {
LOGGER.warn("Cannot create Arbiter, no Spring Environment provided");
return null;
}
The fix should be propagated to the Spring Boot project.