##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集合容器,循环调用输出日志到文件或控制台