The log framework only prints out the configuration of MyBatis SQL

Source: Internet
Author: User
Tags log4j

The project is relatively large, a variety of chaotic framework. The log4j is configured with the info level.

However, I need log4j to print out the execution of SQL when I develop today.

First change the rootlogger level of log4j to debug ... The result is a variety of logs flying.

Log4j.rootLogger=DEBUG, stdout
Log4j.logger.org.apache=ERROR
#log4j.logger.org.hibernate=ERROR #Not used, blocked
Log4j.logger.org.springframework=ERROR
Log4j.logger.org.mybatis=DEBUG
Log4j.logger.org.apache.http=ERROR
Log4j.logger.com.netflix=ERROR
Log4j.appender.stdout=org.apache.log4j.ConsoleAppender
Log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p %d %C: %m%n 

log4j mybatis Print out SQL, do not print the configuration of logs of other frames

Another way to print

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <property name="LOG_HOME" value="${catalina.base}/logs" />
    <property name="PROJECT_NAME" value="dgdr" />
    <property name="ENCODING" value="UTF-8" />
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> 
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}- %msg%n</pattern>
        </encoder>
    </appender>
    <root level="DEBUG">
        <appender-ref ref="STDOUT" />
    </root> 
    <logger name="com.github" level="INFO" />
    <logger name="org" level="INFO"/>
    <logger name="net" level="INFO"/>
    <logger name="org.mybatis" level="DEBUG"/>
   <logger name="java.sql" level="DEBUG" />  
</configuration>

The log framework only prints out the configuration of MyBatis SQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.