commons-logging包含log4j和jdklog。

commons-logging:

1 Log log= LogFactory.getLog(getClass());//commons logging log
2 log.info("===========info=========");

 

log4j:

1 Logger logger= Logger.getLogger(getClass());//log4j log
2 logger.info("++++++++++++log4j info++++++++");

 

jdklog

1 Logger logger2= Logger.getLogger("");
2 logger2.info("+++++++++++++++info jdklog++++++++");

 

当项目classpath里没有log4j的依赖时,那么如果调用commons-logging,实际是使用的jdklog的API

当项目classpath里   有log4j的依赖时,那么如果调用commons-logging,实际是使用的log4j  的API。

注意:使用log4j,必须配置log4j.properties文件。配置可参考:http://blog.csdn.net/qq_30175203/article/details/52084127

相关文章:

  • 2022-12-23
  • 2021-11-16
  • 2021-11-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2021-10-20
  • 2021-10-19
  • 2021-11-29
相关资源
相似解决方案