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

23 篇文章 0 订阅
5 篇文章 0 订阅
/* 从方法级扩展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;
		}
	}

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

游语

对你有帮助,可以请我喝杯奶哦

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值