标签:
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
标签:
原文地址:http://www.cnblogs.com/TheoryDance/p/4943151.html