You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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) NullPointerExceptions 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");
returnnull;
}
Most Log4j configurations in Spring Boot are used twice: with no
environment and with an environment present. Therefore the Spring Boot
arbiter should not fail with no environment.
Fixesapache#1783.
ppkarwasz
added a commit
to ppkarwasz/logging-log4j2
that referenced
this issue
Oct 6, 2023
Most Log4j configurations in Spring Boot are used twice: with no
environment and with an environment present. Therefore the Spring Boot
arbiter should not fail with no environment.
Fixesapache#1783.
Most Log4j configurations in Spring Boot are used twice: with no
environment and with an environment present. Therefore the Spring Boot
arbiter should not fail with no environment.
Fixes#1783.
Description
In a Spring Boot application Log4j Core is initialized at least twice:
Environment
is not available yet),Environment
. It can use the same configuration file as the first one.On the other hand the builder of
SpringProfileArbiter
returnsnull
if no SpringEnvironment
is present, which causes (handled)NullPointerException
s inAbstractConfiguration#processConditionals
orAbstractConfiguration#processSelect
.Since the arbiter logic itself accepts a
null
environment, we should remove the following null-check:The fix should be propagated to the Spring Boot project.
The text was updated successfully, but these errors were encountered: