java配置日志总结
log4j
搭建日志环境
简单非maven项目,只需要引入log4j.jar,在类路径下添加log4j.properties即可
简单maven项目,只需要在pom.xml引入dependency,在类路径下添加resources下添加log4j.properties即可
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
maven+spring项目,需要同时引入三个jar,如下;在类路径下添加resources下添加log4j.properties即可
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.12</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
</dependency>