Snowfun

导航

 

1、导入包log4j-1.2.17.jar

<dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

 

2、创建并设置log4j.properties

 

log4j.rootLogger=info,fileLogger
log4j.appender.fileLogger=org.apache.log4j.DailyRollingFileAppender
log4j.appender.fileLogger.DatePattern='.'yyyy-MM-dd-HH
log4j.appender.fileLogger.File=G:/po/apache-tomcat-7.0.79/logs/error.log
log4j.appender.fileLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.fileLogger.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}]\: %-5r [%-5p] %m%n

 

3、测试类

4、日志信息

posted on 2018-02-12 17:48  Snowfun  阅读(215)  评论(0编辑  收藏  举报