java项目log4j日志打印配置

时间:2021-08-30 02:01:51

#定义输出级别和输出平台  添加DEBUG表示打印sql 语句

log4j.rootLogger=DEBUG,INFO,ERROR,stdout,R

log4j.category.org.springframework = INFO
log4j.category.freemarker = INFO
log4j.category.org.mybatis.spring=INFO
log4j.category.net.joyphper = DEBUG

### appender.R输出到日志文件 ###

log4j.appender.R=org.apache.log4j.DailyRollingFileAppender

#日志文件保存目录和文件名称
log4j.appender.R.File=E:/logs/fenxiao/logger.log

log4j.appender.R.DatePattern=.yyyy-MM-dd

### appender.stdout输出到控制台 ###

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss} [%c] <%m>%n

参考文档

http://blog.csdn.net/janestone/article/details/1862678

http://lzhw1985.iteye.com/blog/1940880