Spring boot logback日志框架加载初始化源码

##LoggingApplicationListener监听

java 复制代码
@Override
	public void onApplicationEvent(ApplicationEvent event) {
		if (event instanceof ApplicationStartingEvent) {
			onApplicationStartingEvent((ApplicationStartingEvent) event);
		}
		else if (event instanceof ApplicationEnvironmentPreparedEvent) {
			onApplicationEnvironmentPreparedEvent((ApplicationEnvironmentPreparedEvent) event);
		}
		else if (event instanceof ApplicationPreparedEvent) {
			onApplicationPreparedEvent((ApplicationPreparedEvent) event);
		}
		else if (event instanceof ContextClosedEvent
				&& ((ContextClosedEvent) event).getApplicationContext().getParent() == null) {
			onContextClosedEvent();
		}
		else if (event instanceof ApplicationFailedEvent) {
			onApplicationFailedEvent();
		}
	}

##初始化

java 复制代码
protected void initialize(ConfigurableEnvironment environment, ClassLoader classLoader) {
		new LoggingSystemProperties(environment).apply();
		this.logFile = LogFile.get(environment);
		if (this.logFile != null) {
			this.logFile.applyToSystemProperties();
		}
		this.loggerGroups = new LoggerGroups(DEFAULT_GROUP_LOGGERS);
		initializeEarlyLoggingLevel(environment);
		initializeSystem(environment, this.loggingSystem, this.logFile);
		initializeFinalLoggingLevels(environment, this.loggingSystem);
		registerShutdownHookIfNecessary(environment, this.loggingSystem);
	}

##Spring boot 集成logback日志框架

org.springframework.boot.logging.logback.LogbackLoggingSystem

this.loggingSystem = LoggingSystem.get(event.getSpringApplication().getClassLoader());

##String logConfig = environment.getProperty(CONFIG_PROPERTY);//取出配置文件log xml配置

##解析xml文档

##实例化xml配置节点日志对象ch.qos.logback.core.rolling.RollingFileAppender

##日志对象存到这个InterpretationContext上下文

##添加到appenderList集合容器,循环调用输出日志到文件或控制台

相关推荐
p***97614 分钟前
SpringBoot(7)-Swagger
java·spring boot·后端
j***294816 分钟前
springboot集成onlyoffice(部署+开发)
java·spring boot·后端
张较瘦_25 分钟前
Springboot | Spring Boot 3 纯 JDBC 实现宠物管理系统增删改查(无 ORM 框架)
spring boot·后端·数据库开发
h***67373 小时前
SpringBoot整合easy-es
spring boot·后端·elasticsearch
叫致寒吧4 小时前
Tomcat详解
java·tomcat
S***26758 小时前
基于SpringBoot和Leaflet的行政区划地图掩膜效果实战
java·spring boot·后端
马剑威(威哥爱编程)9 小时前
鸿蒙6开发视频播放器的屏幕方向适配问题
java·音视频·harmonyos
JIngJaneIL9 小时前
社区互助|社区交易|基于springboot+vue的社区互助交易系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·社区互助