Springboot consolidation mybatis Print SQL to log (GO)

Source: Internet
Author: User

When the foreground request data, the SQL statement has been printed to the console, there is an idea is to let it print to the log, how to do?

See the following mybatis configuration file:

[HTML]View PlainCopyPrint?
  1. <? XML version="1.0" encoding="UTF-8" ?>
  2. <! DOCTYPE configuration Public "-//mybatis.org//dtd Config 3.0//en" "Http://mybatis.org/dtd/mybatis-3-config.dtd" >
  3. < Configuration >   
  4. <!--set Run parameters --   
  5. < Settings >   
  6. <!--Global Mapper Enable cache --   
  7. < setting  name="cacheenabled" value="true" />
  8. < when!--query, close the associated object and load it in time to improve performance--   
  9. < setting name="lazyloadingenabled" value="false" />
  10. <!--Set the shape of the associated object load, where the field is loaded on demand (the Load field is specified by SQL) and all fields of the associated table are not loaded to improve performance --   
  11. < setting name="aggressivelazyloading" value="false" />
  12. <!--SQL queries for locations, allowing different result sets to be returned to achieve a common effect--   
  13. < setting name="multipleresultsetsenabled" value=" True " />
  14. <!--allow column labels to be used instead of columns --   
  15. < setting name="Usecolumnlabel" value="true" />
  16. <!--allows you to use a custom primary key value (such as a program-generated UUID 32-bit encoding as the key value), and the PK generation strategy for the data table will be overwritten -   
  17. < setting name="Usegeneratedkeys" value="true" />
  18. <!--given nested resultmap with field-property mapping support-   
  19. < setting name="Automappingbehavior" value="PARTIAL" />
  20. <!--cache SQL for bulk update operations to improve performance --   
  21. < setting name="Defaultexecutortype" value="Reuse" />
  22. <!--The database is still not responding for more than 25,000 seconds timeout -   
  23. < setting name="defaultstatementtimeout" value="25000 " />
  24. <!--print query statements --   
  25. <!--<setting name= "Logimpl" value= "stdout_logging"/> --   
  26. </ Settings >   
  27. </ Configuration >   
<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE configuration Public "-//mybatis.org//dtd Config 3.0//en" "Http://mybatis.org/dtd/mybatis-3-config.dtd" > <configuration> <!--set Run parameters--<settings> <!--Global Mapper Enable Cache--<setting name = "Cacheenabled" value= "true"/> <!--query, close the associated object to load in time to improve performance--<setting name= "lazyloadingenabled" Value= "false"/> <!--sets the form of the associated object load, where the field is loaded on demand (the Load field is specified by SQL) and all fields of the associated table are not loaded to improve performance--<setting name= "AG Gressivelazyloading "value=" false "/> <!--SQL query for location, allowing different result sets to be returned to achieve a common effect--<setting name=" mult Ipleresultsetsenabled "value=" true "/> <!--allow column labels to be used instead of columns--<setting name= ' Usecolumnlabel ' value = "true"/> <!--allow the use of custom primary key values (such as the program-generated UUID 32-bit encoding as the key value), the data table PK generation strategy will be overwritten--<setting name= "Usegenera Tedkeys "value=" true "/> <!--gives nested resultmap with field-property mapping support--<setting name=" aUtomappingbehavior "value=" PARTIAL "/> <!--cache SQL for bulk update operations to improve performance--<setting name=" Defaultexecuto Rtype "value=" Reuse "/> <!--database is still not responding for more than 25,000 seconds timeout---<setting name=" Defaultstatementtimeout "Valu     E= "25000"/> <!--print Query statements-<!--<setting name= "Logimpl" value= "stdout_logging"/>-- </settings></configuration>

[HTML]View PlainCopyPrint?
    1. < setting name="Logimpl" value="Stdout_ LOGGING " />
<setting name= "Logimpl" value= "stdout_logging"/>

That's the sentence!

If you annotate it, your SQL can print into the log

If you let it go, your SQL will print to the console


How to configure the log printing in the Springboot? You can refer to another article:

Use Logback to print logs in Springboot



Springboot consolidation mybatis Print SQL to log (GO)

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.