今天看 spring api , spring 建议采用SLF4J而不是Commons Logging,原因如下:
SLF4J is a cleaner dependency and more efficient at runtime than commons-logging because it uses compile-time bindings instead of runtime discovery of the other logging frameworks it integrates
我理解为:SLF4J采用的策率是编译时绑定,而commons-logging 采用的是运行时查找的算法.所以采用SLF4j会使写出来的代码效率更高,原来对日志系统一直没怎么在意,没想到还有这些说法啊.
原来写代码的时候总是发现有一个commons-logging.jar的依赖,
现在直接移除了,maven依赖如下:
SLF4J is a cleaner dependency and more efficient at runtime than commons-logging because it uses compile-time bindings instead of runtime discovery of the other logging frameworks it integrates
我理解为:SLF4J采用的策率是编译时绑定,而commons-logging 采用的是运行时查找的算法.所以采用SLF4j会使写出来的代码效率更高,原来对日志系统一直没怎么在意,没想到还有这些说法啊.
原来写代码的时候总是发现有一个commons-logging.jar的依赖,
现在直接移除了,maven依赖如下:
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.0.RELEASE</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>runtime</scope>
</dependency>
</dependencies>