码迷,mamicode.com
首页 > 其他好文 > 详细

log4j

时间:2015-11-06 18:02:45      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

package common;

import org.apache.log4j.Logger;

public class MyLogger {
	public static Logger logger = Logger.getLogger(MyLogger.class);
}

  定制输出样式

 # ConversionPattern
 # %p-->debug,info,warn,error,fatal
 # %t-->thread name 
 # %c-->class name and package name
 # %M-->method name
 # %l-->happen place line(include package.class.method(line))
 # %L-->line eg:(9)
 # %m-->message
 # %n-->enter.  if system is windows \r\n,Unix \n
 # %d-->date default ISO9601, eg:%d{yyyy-MM-dd HH:mm:ss:SSS},hours HH is 24,hh is 12

  web.xml

<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>classpath:log4j/log4j.properties</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
  </listener>

  log4j.properties

log4j.rootLogger=debug, stdout, logfile
   
log4j.logger.com.ibatis=DEBUG
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
   
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.logger.java.sql.ResultSet=DEBUG
  
log4j.logger.org.springframework=ERROR
log4j.logger.org.compass=ERROR
  
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
   
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=empi.log

  

log4j

标签:

原文地址:http://www.cnblogs.com/TheoryDance/p/4943151.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!