spring日志插件

Apache为了让众多的日志工具有一个相同操作方式,实现了一个通用日志工具包:commons-logging,

commons-logging能在运行时决定使用哪种日志组件(如Log4j),如果什么都没找到,会使用JDK的LOG。

现在,Apache通用日志工具commons-logging和Log4j已经成为Java日志的标准工具。

所以,commons-logging与Log4j是合作关系

安装:

spring-core强制指定使用common-logging模块,在maven中只需要配置spring-core就行了,例如:
<dependencies>
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>4.2.5.RELEASE</version>
  </dependency>
</dependencies>
值得强调的是log4j是运行时绑定,即相当于common-logging在运行时绑定了log4j,配置例如:
<dependencies>
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>4.2.5.RELEASE</version>
  </dependency>
  <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.14</version>
  </dependency>
</dependencies>

猜你喜欢

转载自www.cnblogs.com/yanze/p/10595427.html