java日志
Component
|
| log to Apache Commons Logging
V
jcl-over-slf4j.jar --- (redirect) ---> SLF4j ---> slf4j-log4j12-version.jar ---> log4j.jar ---> 输出日志
看到上面的流程图可能会发现一个有趣的问题,假如在 CLASS_PATH 里同时放置 log4j-over-slf4j.jar 和 slf4j-log4j12-version.jar 会发生什么情况呢?没错,日志会被踢来踢去,最终进入死循环。
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
SLF4JLogFactory
private final static Log log = LogFactory.getLog(订单日志.class); jcl-over-slf4j-1.7.5.jar
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static Logger log = LoggerFactory.getLogger(订单日志.class); slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar