common-logging
在springframework的spring-core中強(qiáng)制指定了使用common-logging模塊癞尚,該模塊是標(biāo)準(zhǔn)的實(shí)現(xiàn)至Jarka Common Log(JCL)的浪慌,并在runtime運(yùn)行時(shí)自動(dòng)發(fā)現(xiàn)其它框架選擇的日志組件泊交,并定位一個(gè)認(rèn)為最接近的日志組件作為應(yīng)用日志(如果什么都沒找到呻引,會(huì)使用JDK的LOG颜及,(java.util.logging or JUL for short))掖肋,在maven中只需要配置了spring-core就有了
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.5.RELEASE</version>
</dependency>
</dependencies>
SLF4J
使用SLF4J(Simple Log Factory For JAVA)需要將common-logging排除仆葡,同時(shí)需要使用SL4J橋接,將springframework的common-logging橋接到SL4J上志笼,所以需要4個(gè)依賴沿盅,同時(shí)排除spring-core中自帶的common-logging,使用maven如下
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.5.RELEASE</version>
<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>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
</dependencies>
log4j
使用log4j時(shí)不需要排除spring-core中的common-logging纫溃,同時(shí)log4j也是運(yùn)行時(shí)綁定腰涧,相當(dāng)于common-logging在運(yùn)行時(shí)綁定了log4j,maven如下
<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>