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]]
  • 相关阅读:
    Dynamics CRM开发参考资料
    Sql Server存储过程和游标的配合操作
    C#字符处理的性能问题
    Windows安装完ADFS后卸载ADFS清除ADFS数据库
    C#修改AD账号及密码
    Dynamics CRM安装教程九(续):自建证书的CRM项目客户端设置CRM访问
    Kubernetes实践之深入掌握Pod——Pod健康检查和服务可用性检查
    Kuberbetes实践——镜像拉取策略、command args参数、Pod生命周期和重启策略
    Kubernetes实践之深入掌握Pod——在容器内获取Pod信息
    Kubernetes实践之深入掌握Pod——ConfigMap
  • 原文地址:https://www.cnblogs.com/hylinux/p/6503311.html
Copyright © 2011-2022 走看看