zoukankan      html  css  js  c++  java
  • 【Mybaits学习】04_ 优化调试信息(log4j)

    1、增加Log4j Jar包

    		<!-- https://mvnrepository.com/artifact/log4j/log4j -->
    		<dependency>
    			<groupId>log4j</groupId>
    			<artifactId>log4j</artifactId>
    			<version>1.2.17</version>
    		</dependency>

    2、新建以及配置log4j文件

    log4j.propertiesuFF0C
    log4j.rootLogger=DEBUG, Console
    #Console
    log4j.appender.Console=org.apache.log4j.ConsoleAppender
    log4j.appender.Console.layout=org.apache.log4j.PatternLayout
    log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
    log4j.logger.java.sql.ResultSet=INFO
    log4j.logger.org.apache=INFO
    log4j.logger.java.sql.Connection=DEBUG
    log4j.logger.java.sql.Statement=DEBUG
    log4j.logger.java.sql.PreparedStatement=DEBUG

    3、执行测试代码,已上次CRUD为例

    2017-03-04 23:35:10,441 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.getUser] - ==>  Preparing: select * from user where id = ? 
    2017-03-04 23:35:10,465 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.getUser] - ==> Parameters: 2(Integer)
    2017-03-04 23:35:10,487 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.getUser] - <==      Total: 1
    User [id=2, name=Jack, age=17]
    2017-03-04 23:35:10,487 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.addUser] - ==>  Preparing: insert into user(name,age) values(?,?) 
    2017-03-04 23:35:10,488 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.addUser] - ==> Parameters: niuh(String), 11(Integer)
    2017-03-04 23:35:10,541 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.addUser] - <==    Updates: 1
    1
    2017-03-04 23:35:10,542 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.getAllUser] - ==>  Preparing: select * from user 
    2017-03-04 23:35:10,542 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.getAllUser] - ==> Parameters: 
    2017-03-04 23:35:10,551 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.getAllUser] - <==      Total: 7
    [User [id=2, name=Jack, age=17], User [id=4, name=niuh, age=11], User [id=5, name=niuh, age=11], User [id=6, name=niuh, age=11], User [id=7, name=niuh, age=11], User [id=8, name=niuh, age=11], User [id=9, name=niuh, age=11]]
    2017-03-04 23:35:10,552 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.deleteUser] - ==>  Preparing: delete from user where id = ? 
    2017-03-04 23:35:10,553 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.deleteUser] - ==> Parameters: 1(Integer)
    2017-03-04 23:35:10,555 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.deleteUser] - <==    Updates: 0
    0
    2017-03-04 23:35:10,556 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.getAllUser] - ==>  Preparing: select * from user 
    2017-03-04 23:35:10,556 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.getAllUser] - ==> Parameters: 
    2017-03-04 23:35:10,562 [main] DEBUG [nh.ui.automation.tools.mapper.UserMapper.getAllUser] - <==      Total: 7
    [User [id=2, name=Jack, age=17], User [id=4, name=niuh, age=11], User [id=5, name=niuh, age=11], User [id=6, name=niuh, age=11], User [id=7, name=niuh, age=11], User [id=8, name=niuh, age=11], User [id=9, name=niuh, age=11]]
  • 相关阅读:
    监考
    初步确定五一粤东出行计划
    煤矿粉尘监控系统中心站软件3层设计
    c# 程序调用代码生成数据库
    Socket 一个服务器监听多个客户端 功能实现
    软件开发进度表
    sql server日期时间格式转换字符串简介
    Sql建表和sql语句的注意事项
    分布式设计与开发(一)宏观概述
    分布式设计与开发(四)数据拆分
  • 原文地址:https://www.cnblogs.com/hylinux/p/6503311.html
Copyright © 2011-2022 走看看