zoukankan      html  css  js  c++  java
  • *MyBatis框架 在控制台打印sql语句

    在 log4j.properties  中将这段代码添加进去就好了
    #
    log4j.rootLogger=INFO, 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=DEBUG
    log4j.logger.org.apache=ERROR
    log4j.logger.java.sql.Connection=DEBUG
    log4j.logger.java.sql.Statement=DEBUG
    log4j.logger.java.sql.PreparedStatement=DEBUG

    #####就上面这一点内容,下面是我的某个项目中 log4j.properties  的源码

    # Set root category priority to INFO and its only appender to CONSOLE.
    log4j.rootCategory=DEBUG,CONSOLE,LOGFILE,LOGERROR
    #log4j.rootCategory=INFO, CONSOLE, LOGFILE


    # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
    log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
    log4j.appender.CONSOLE.Threshold=DEBUG
    log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
    #log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
    log4j.appender.CONSOLE.Target=System.out
    log4j.appender.CONSOLE.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n
    log4j.appender.CONSOLE.Encoding=UTF-8

    #
    log4j.rootLogger=INFO, 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=DEBUG
    log4j.logger.org.apache=ERROR
    log4j.logger.java.sql.Connection=DEBUG
    log4j.logger.java.sql.Statement=DEBUG
    log4j.logger.java.sql.PreparedStatement=DEBUG
    #

    # LOGFILE is set to be a File appender using a PatternLayout.
    # log4j.appender.LOGFILE=org.apache.log4j.DailyRollingFileAppender
    # log4j.appender.LOGFILE.DatePattern='.'yyyy-MM-dd
    # log4j.appender.LOGFILE.File=${catalina.base}/logs/APPLog.log
    # log4j.appender.LOGFILE.Threshold=INFO
    # log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
    # log4j.appender.LOGFILE.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n
     
    log4j.appender.LOGFILE=org.apache.log4j.DailyRollingFileAppender
    #uFF08u5B89u88C5u76EEu5F55uFF09IBMWebSphereAppServerprofilesAppSrv01logsserver1
    log4j.appender.LOGFILE.File=${catalina.base}/logs/info.log
    log4j.appender.LOGFILE.DatePattern='.'yyyy-MM-dd
    log4j.appender.LOGFILE.Append=true
    log4j.appender.LOGFILE.Threshold=INFO
    log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
    log4j.appender.LOGFILE.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss.SSS} [%c]-[%p] %m%n
    log4j.appender.LOGFILE.Encoding=UTF-8


    log4j.appender.LOGERROR=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.LOGERROR.File=${catalina.base}/logs/error.log
    log4j.appender.LOGERROR.DatePattern='.'yyyy-MM-dd
    log4j.appender.LOGERROR.Append=true
    log4j.appender.LOGERROR.Threshold=ERROR
    log4j.appender.LOGERROR.layout=org.apache.log4j.PatternLayout
    log4j.appender.LOGERROR.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss.SSS} [%c]-[%p] %m%n
    log4j.appender.LOGERROR.Encoding=UTF-8
    # Set the enterprise logger category to FATAL and its only appender to CONSOLE.
    #log4j.logger.com.qualcomm=DEBUG
    log4j.logger.org.acegi=ERROR
    log4j.logger.com.svw.tms=DEBUG
    log4j.logger.org.springframework=ERROR
    log4j.logger.org.mybatis=ERROR
    log4j.logger.org.quartz=INFO
    log4j.logger.com.broadtext=DEBUG
    log4j.logger.com.svw.common.workbench=DEBUG
    log4j.logger.com.opensymphony=ERROR
    log4j.logger.com.mchange=ERROR
    log4j.logger.freemarker=ERROR
    log4j.logger.net.sf.ehcache=ERROR

    #log4j.logger.org.hibernate.type=DEBUG

  • 相关阅读:
    jdbc学习一半的代码
    实验室的毕业照
    IOS_地图_定位_天气预报_Block回调_单例
    POJ -1062 昂贵的聘礼(前向星 && SPFA)
    【监控】Nagios-NRPE脚本返回值
    cocos2d-x-3.0 Windos 新建项目(coco2d-x 学习笔记一)
    托付与事件
    Netty源代码学习——EventLoopGroup原理:NioEventLoopGroup分析
    vs2013 error c4996: 'fopen': This function or variable may be unsafe
    Customize User Interfaces and Pass User Input to Installer Classes
  • 原文地址:https://www.cnblogs.com/renpei/p/5482378.html
Copyright © 2011-2022 走看看