【spring-boot】spring-boot框架日志框架加载过程实现
一、整体流程
1、spring-boot的jar包,中META-INF/spring.factories文件会在spring容器中注入ApplicationListener接口实现
org.springframework.context.ApplicationListener=\
org.springframework.boot.ClearCachesApplicationListener,\
org.springframework.boot.builder.ParentContextCloserApplicationListener,\
org.springframework.boot.context.FileEncodingApplicationListener,\
org.springframework.boot.context.config.AnsiOutputApplicationListener,\
org.springframework.boot.context.config.ConfigFileApplicationListener,\
org.springframework.boot.context.config.DelegatingApplicationListener,\
org.springframework.boot.context.logging.ClasspathLoggingApplicationListener,\
org.springframework.boot.context.logging.LoggingApplicationListener,\
org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener
2、其中org.springframework.boot.context.logging.LoggingApplicationListener会在容器启动前,进行日志装配功能

3、org.springframework.boot.logging.LoggingSystem会通过反射,尝试在当前项目中依次加载如下配置的类,加载到那个,则使用哪个作为当前项目的日志框架

4、如加载到org.apache.logging.log4j.core.impl.Log4jContextFactory类,则使用org.springframework.boot.logging.log4j2.Log4J2LoggingSystem类初始化日志框架
浙公网安备 33010602011771号