MyBatis3-configure to output logs using log4j, mybatis3-log4j

Source: Internet
Author: User

MyBatis3-configure to output logs using log4j, mybatis3-log4j

Configuration steps:

1. Introduce POM Dependencies

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

2. Add log4j. properties to resources. The content is as follows:

log4j.rootLogger=DEBUG,Consolelog4j.appender.Console=org.apache.log4j.ConsoleAppenderlog4j.appender.Console.layout=org.apache.log4j.PatternLayoutlog4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%nlog4j.logger.org.apache=INFO#ex:http://www.cnblogs.com/zhaozihan/p/6371133.html

Of course, there are many more detailed configurations on the Internet. You can search for them. Here we use the configuration of http://www.cnblogs.com/zhaozihan/p/6371133.html.

3. Add the following Configuration in Configuration. xml:

    <properties>        <property name="dialect" value="mysql" />    </properties>    <settings>        <setting name="logImpl" value="LOG4J" />    </settings>

After configuration, the running effect is as follows:

Key configurations of log output:<Setting name = "logImpl" value = "LOG4J"/>Only after this sentence is configured can the SQL statement be output normally.

If other log components need to be configured, you can use this option to specify the type of log components. Reference: http://www.mybatis.org/mybatis-3/zh/configuration.html#settings

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.