配置日志框架log4j

建立log4j配置文件(log4j.properties)
#全局日志配置
log4j.rootLogger=ERROR,stdout
#MyBatis日志配置
log4j.logger.org.fkit.mapper.UserMapper=DEBUG
#控制台输出
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
同时,在控制台可以观察到执行时的日志信息,其中包括了MyBatis说执行的SQL语句
15:45:46,651 DEBUG save:159 - ==>  Preparing: INSERT INTO tb_user(NAME,SEX,AGE) VALUES(?,?,?)
15:45:46,686 DEBUG save:159 - ==> Parameters: admin(String), m(String), 22(Integer)
15:45:46,694 DEBUG save:159 - <==    Updates: 1