log4j 和common-logging

来源:互联网 发布:虚拟机和系统网络连接 编辑:程序博客网 时间:2024/05/01 22:29

今天 log的时候 总是classnotfound   common-logging

后来添加了如下的代码就好了。

<dependency><groupId>org.slf4j</groupId><artifactId>jcl-over-slf4j</artifactId><version>1.6.2</version></dependency>


网上的具体解释是:

如果在原有commons-logging 系统里,如果要迁移到slf4j, 使用slf4j 替换commons-logging ,也是可以做到的。原理使用到了上述commons-logging 加载的第二点。需要引入Org.slf4j.jcl-over-slf4j-1.5.6.jar 。这个jar 包提供了一个桥接,让底层实现是基于slf4j 。原理是在该jar 包里存放了配置META-INF/services/org.apache.commons.logging.LogFactory =org.apache.commons.logging.impl.SLF4JLogFactory ,而commons-logging 在初始化的时候会找到这个serviceId ,并把它作为LogFactory 。

http://www.iteye.com/topic/934593   java日志,需要知道的几件事


就是说要替换调原来的commons-logging .
很开心~~~