Cycle in LogAdapter.Log4jLog initialization within log appender #24440
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: regression
A bug that is also a regression
Milestone
Affects: 5.2.x
The Spring implementation of commons-logging has the following logic within the
LogAdapter
for Log4j2...If a custom appender depends on a class that has a static logger defined, we get an NPE on the
loggerContext
because the constructor is called before the static field is initialized.For the full context of the issue, see spring-projects/spring-amqp-samples#59 and spring-projects/spring-amqp#1148. The work-around was to defer initialization of the classes with the static loggers until the log system is initialized.
This may be an unsolvable catch-22 but I thought I should at least raise the issue in case the Spring Team has ideas. This was not an issue with Boot 1.5/Spring 4.3.
Here is a simple example that exhibits the behavior:
The text was updated successfully, but these errors were encountered: