spring日誌插件
阿新 • • 發佈:2019-03-25
color 需要 gin mave pri spa ons end str
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>
spring日誌插件