com.emily.infrastructure.logger.LoggerAutoConfiguration Maven / Gradle / Ivy
package com.emily.infrastructure.logger;
import com.emily.infrastructure.logback.factory.LoggerFactory;
import org.slf4j.Logger;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
/**
* LogBack日志组件,加载配置文件优先级:...
* 加载顺序:logback-test.xml->logback.xml->SPI com.qos.logback.classic.spi.Configurator模式->BasicConfigurator打印控制台
*
* @author Emily
* @see ...
* @since : 2020/08/08
*/
@AutoConfiguration
@EnableConfigurationProperties(LoggerProperties.class)
@ConditionalOnProperty(prefix = LoggerProperties.PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true)
public class LoggerAutoConfiguration implements InitializingBean, DisposableBean {
private static final Logger logger = LoggerFactory.getLogger(LoggerAutoConfiguration.class);
@Override
public void destroy() {
logger.info("<== 【销毁--自动化配置】----Logger日志组件【LoggerAutoConfiguration】");
}
@Override
public void afterPropertiesSet() {
logger.info("==> 【初始化--自动化配置】----Logger日志组件【LoggerAutoConfiguration】");
}
}