利⽤log4j打印sql的log⽇志
默认情况下,使⽤ibatis是不打印ibatis相关的log的,因为内部的sql执⾏都是内部调⽤,在server的控制台是不会打印log 的。log4j2不打印日志
在log4j的配置⽂件log4j.properties⾥加上以下⼏句话就可以了:
log4j.logger.bill99.base=INFO
log4j.p=INFO
log4j.lden.inf.sso=INFO
log4j.logger.bill99.mdp=INFO
log4j.logger.bill99=INFO
#log4j.additivity.bill99=false
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=e\:\\opt\\log\\app-coe-prm.log
log4j.appender.logfile.MaxFileSize=10MB
# Keep three backup files.
log4j.appender.logfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %t [%l]%m%n
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
#  SqlMap  logging 
log4j.logger.java.sql.Connection=INFO
log4j.logger.java.sql.Statement=INFO
log4j.logger.java.sql.PreparedStatement=INFO
log4j.logger.java.sql.ResultSet=INFO
使⽤如下配置可以查看sql语句中?代表的实际参数:
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
hibernate=debug
hibernate.hql.ast.AST=debug
#下⾯的两条配置⾮常重要,设置为trace后,将可以看到打印出sql中?占位符的实际内容
#this is the most important config for showing parames like ?
hibernate.SQL=trace
pe=trace
#above two configs
l.hbm2ddl=debug
hibernate.hql=debug
hibernate.cache=debug
ansaction=debug
hibernate.jdbc=debug
tion.DriverManagerConnectionProvider=trace
pe.descriptor.sql.BasicBinder=TRACE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n    hibernate=debug
hibernate.hql.ast.AST=debug
#下⾯的两条配置⾮常重要,设置为trace后,将可以看到打印出sql中?占位符的实际内容
#this is the most important config for showing parames like ?
hibernate.SQL=trace
pe=trace
#above two configs
l.hbm2ddl=debug
hibernate.hql=debug
hibernate.cache=debug
ansaction=debug
hibernate.jdbc=debug
tion.DriverManagerConnectionProvider=trace
pe.descriptor.sql.BasicBinder=TRACE

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。