It is recommended not to initialize the log configuration recursively, which will lead to unnecessary memory occupation

When calling the LoggingSystem#getLoggerConfigurations method, you only need to return the log level configured by the developer, because others are default

For example, I only configured logging.level.com.bruce.consumer.controller=debug, so there is no need to create a LoggerConfig object for com.bruce, Lazy loading is more reasonable

https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java#L275,#L278

SpringBoot It is recommended not to initialize the log configuration recursively, which will lead to unnecessary memory occupation

However, in the implementation of logback, logback will recursively create logger objects. This is a bad design because it wastes memory. Maybe an issue should also be submitted to logback to optimize this problem.

For example, I only configured logging.level.com.bruce.consumer.controller=debug, so there is no need to create a Logger object for com.bruce, Lazy loading is more reasonable

@see ch.qos.logback.classic.LoggerContext#getLogger(java.lang.String)

SpringBoot It is recommended not to initialize the log configuration recursively, which will lead to unnecessary memory occupation

Comment From: philwebb

We specifically want logging configurations to be included in the result of LoggingSystem#getLoggerConfigurations because it's used by the actuator endpoint. Without them JSON payload would be incomplete. I'm not sure we have an easy way to calculate what the default would be without calling Configuration.getLoggerConfig(...).

All things considered, I think the memory occupation isn't too much of a problem and is a better tradeoff than the maintenance costs of making the code more complex.