Meavn项目中log4j的使用
两个步骤:
1.在pom.xml中添加:
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency>
2.resources中添加log4j.properties文件
### set log levels ### log4j.rootLogger = DEBUG,Console,File ### \u8F93\u51FA\u5230\u63A7\u5236\u53F0 ### log4j.appender.Console=org.apache.log4j.ConsoleAppender log4j.appender.Console.Target=System.out log4j.appender.Console.layout=org.apache.log4j.PatternLayout log4j.appender.Console.layout.ConversionPattern= %d{ABSOLUTE} %5p %c{1}:%L - %m%n ### \u8F93\u51FA\u5230\u65E5\u5FD7\u6587\u4EF6 ### log4j.appender.File=org.apache.log4j.RollingFileAppender log4j.appender.File.File=${project}/WEB-INF/logs/app.log log4j.appender.File.DatePattern=_yyyyMMdd'.log' log4j.appender.File.MaxFileSize=10MB log4j.appender.File.Threshold=ALL log4j.appender.File.layout=org.apache.log4j.PatternLayout log4j.appender.File.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH\:mm\:ss,SSS}][%c]%m%n