1 当时debug的时候 遇到了一些问题,想看后台输出情况,但是了 日志打印太多了,什么apache启动 spring struts2 mybatis启动 的日志都有,杂糅在一起。而我只想看sql语句的执行和结果。这里只需要把日志打印的级别改为INFO 以前的是DEBUG 级别稍微提高一点。
#Log4j常用的优先级:
FATAL>ERROR>WARN>INFO>DEBUG
#log4j.addivity.org.apache=true
###################
#log4j.appender.Threshold=INFO
#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{yyyy-MM-dd HH\:mm\:ss} %-5p - %c - %m%n
###################
#log4j.logger.com.ibatis=INFO,EBAS_FILE
#log4j.logger.java.sql.PreparedStatement=DEBUG,EBAS_FILE
#log4j.logger.java.sql.ResultSet=DEBUG,EBAS_FILE
############################
#log4j.appender.EBAS_FILE=org.apache.log4j.RollingFileAppender
#log4j.appender.EBAS_FILE.Threshold=INFO
#log4j.appender.EBAS_FILE.File=${catalina.home}/ebas/logs/EBAS.log
#log4j.appender.EBAS_FILE.Append=true
#log4j.appender.EBAS_FILE.MaxFileSize=3MB
#log4j.appender.EBAS_FILE.MaxBackupIndex=5
#log4j.appender.EBAS_FILE.layout=org.apache.log4j.PatternLayout
#log4j.appender.EBAS_FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} %-5p - %c.%M(%F\:%L) - %m%n
这个是以前的配置,导致后台输出所有日志 不容易看
现在的配置如下:
log4j.rootCategory=INFO, stdout, EBAS
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d-[HL] %p %t %c - %m%n
log4j.logger.org.springframework=INFO,EBAS
log4j.logger.com.belter=INFO,EBAS
# SqlMap logging configuration...
log4j.logger.java.sql.ResultSet=DEBUG,EBAS
log4j.logger.org.apache=INFO,EBAS
log4j.logger.java.sql.Connection=DEBUG,EBAS
log4j.logger.java.sql.Statement=DEBUG,EBAS
log4j.logger.java.sql.PreparedStatement=DEBUG,EBAS
##Log Files
log4j.appender.EBAS=org.apache.log4j.DailyRollingFileAppender
log4j.appender.EBAS.File=${catalina.home}/ebas/logs/log.log
log4j.appender.EBAS.layout=org.apache.log4j.PatternLayout
log4j.appender.EBAS.DatePattern ='.'yyyy-MM-dd
log4j.appender.EBAS.layout.ConversionPattern=%d-[HL] %p %t %c - %m%n
这样就只打印sql相关日志了。
#Log4j常用的优先级:
FATAL>ERROR>WARN>INFO>DEBUG
#log4j.addivity.org.apache=true
###################
#log4j.appender.Threshold=INFO
#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{yyyy-MM-dd HH\:mm\:ss} %-5p - %c - %m%n
###################
#log4j.logger.com.ibatis=INFO,EBAS_FILE
#log4j.logger.java.sql.PreparedStatement=DEBUG,EBAS_FILE
#log4j.logger.java.sql.ResultSet=DEBUG,EBAS_FILE
############################
#log4j.appender.EBAS_FILE=org.apache.log4j.RollingFileAppender
#log4j.appender.EBAS_FILE.Threshold=INFO
#log4j.appender.EBAS_FILE.File=${catalina.home}/ebas/logs/EBAS.log
#log4j.appender.EBAS_FILE.Append=true
#log4j.appender.EBAS_FILE.MaxFileSize=3MB
#log4j.appender.EBAS_FILE.MaxBackupIndex=5
#log4j.appender.EBAS_FILE.layout=org.apache.log4j.PatternLayout
#log4j.appender.EBAS_FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} %-5p - %c.%M(%F\:%L) - %m%n
这个是以前的配置,导致后台输出所有日志 不容易看
现在的配置如下:
log4j.rootCategory=INFO, stdout, EBAS
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d-[HL] %p %t %c - %m%n
log4j.logger.org.springframework=INFO,EBAS
log4j.logger.com.belter=INFO,EBAS
# SqlMap logging configuration...
log4j.logger.java.sql.ResultSet=DEBUG,EBAS
log4j.logger.org.apache=INFO,EBAS
log4j.logger.java.sql.Connection=DEBUG,EBAS
log4j.logger.java.sql.Statement=DEBUG,EBAS
log4j.logger.java.sql.PreparedStatement=DEBUG,EBAS
##Log Files
log4j.appender.EBAS=org.apache.log4j.DailyRollingFileAppender
log4j.appender.EBAS.File=${catalina.home}/ebas/logs/log.log
log4j.appender.EBAS.layout=org.apache.log4j.PatternLayout
log4j.appender.EBAS.DatePattern ='.'yyyy-MM-dd
log4j.appender.EBAS.layout.ConversionPattern=%d-[HL] %p %t %c - %m%n
这样就只打印sql相关日志了。