1
ericgui 2020-01-12 08:52:29 +08:00
阿里有日志的库吗?
|
2
xy2401 2020-01-12 10:17:16 +08:00
内容有点少啊。看个开头发现下面没有了
|
3
hantsy 2020-01-12 13:19:46 +08:00
大部分时间调用的 API 只有 Sf4l,JUL。Backend 比较多的有是 Logback,JUL,也有用过 Log4j,JBoss Logging(JBossr 的一个 Logging 套)。
Spring 核心由于历史原因,本来依赖外部 JCL。 Spring 5.0 内部重写那些接口(不需要依赖 JCL 了),将调用 JCL 操作 Delegate 到运行时 Logging,Backend 可以是 sf4l,log4j 1/2,logback 等。 |
5
tunzao OP @hantsy 如果我没有理解错,其实 spring 5 是把 JCL 替换成了 slf4j,依托 slf4j 已经实现的诸多 adapter,从而实现了对目前常用日志实现框架的支持
|
6
hantsy 2020-01-12 21:03:36 +08:00
@tunzao 不是。为了保持兼容,用 JCL 一样的接口,但自己另外实现了。
https://github.com/spring-projects/spring-framework/blob/master/spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java 其中主要调用 LogAdaptor,看看其源代码就明白了。https://github.com/spring-projects/spring-framework/blob/master/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java static { if (isPresent(LOG4J_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. logApi = LogApi.SLF4J_LAL; } else { // Use Log4j 2.x directly, including location awareness support logApi = LogApi.LOG4J; } } else if (isPresent(SLF4J_SPI)) { // Full SLF4J SPI including location awareness support logApi = LogApi.SLF4J_LAL; } else if (isPresent(SLF4J_API)) { // Minimal SLF4J API without location awareness support logApi = LogApi.SLF4J; } else { // java.util.logging as default logApi = LogApi.JUL; } } |