Spring-jcl源码(三) -- LogAdapter创建Log对象过程

/* 从方法级扩展Log4j的Logger类*/
	private static final String LOG4J_SPI = "org.apache.logging.log4j.spi.ExtendedLogger";

	private static final String LOG4J_SLF4J_PROVIDER = "org.apache.logging.slf4j.SLF4JProvider";

	/* 一个非强制性接口,帮助日志记录系统集成提取位置信息*/
	private static final String SLF4J_SPI = "org.slf4j.spi.LocationAwareLogger";

	/* SLF4J的Logger类 */
	private static final String SLF4J_API = "org.slf4j.Logger";

	/* LogApi枚举 */
	private static final LogApi logApi;

	static {
		/* 是否初始化LOG4J_SPI成功*/
		if (isPresent(LOG4J_SPI)) {
			/* 是否初始化LOG4J_SLF4J_PROVIDER和SLF4J_SPI成功 */
			if (isPresent(LOG4J_SLF4J_PROVIDER) && isPresent(SLF4J_SPI)) {
				// log4j-to-slf4j bridge -> we'll rather go with the SLF4J SPI;
				// however, we still prefer Log4j over the plain SLF4J API since
				// the latter does not have location awareness support.
				/* log4j-to-slf4j桥接,我们更倾向于选择slf4j SPI,但是,我们仍然喜欢log4j而不是普通的slf4j API,因为后者没有位置感知支持。 */
				logApi = LogApi.SLF4J_LAL;
			}
			else {
				// Use Log4j 2.x directly, including location awareness support
				/* 直接使用log4j 2.x,包括位置感知支持 */
				logApi = LogApi.LOG4J;
			}
		}
		/* 是否初始化SLF4J_SPI成功*/
		else if (isPresent(SLF4J_SPI)) {
			// Full SLF4J SPI including location awareness support
			/* 完整的SLF4J SPI,包括位置感知支持 */
			logApi = LogApi.SLF4J_LAL;
		}
		/* 是否初始化SLF4J_API成功*/
		else if (isPresent(SLF4J_API)) {
			// Minimal SLF4J API without location awareness support
			/* 阉割版SLF4J API 不包含位置感知支持 */
			logApi = LogApi.SLF4J;
		}
		else {
			// java.util.logging as default
			/* java.util.logging的默认logApi */
			logApi = LogApi.JUL;
		}
	}

 

你可能感兴趣的:(Java,spring,spring-jcl)