Home >Java >javaTutorial >How to configure mybatisplus to enable printing of sql logs under springboot
The following three configurations are required
1: Set the log level under the mybatisplus package to DEBUG;
logging: level: com: baomidou: mybatisplus: DEBUG
2: Set the project mapper directory (dao package path) The log level is DEBUG;
logging: level: com: xxx: xxx xxx: DEBUG
3: Set the log output mode of mybatis-plus to slf4j.
mybatis-plus: #mapper-locations: classpath*:/mappings/**/*.xml configuration: log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
Attachment: Turn off printing
In a production environment, if you do not want to print SQL logs, you can turn it off through the following configuration.
mybatis-plus: configuration: log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
For application.properties file
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.nologging.NoLoggingImpl
If you want to control it through configuration SQL printing effect, you can set the value of log-impl to the value passed in from the outside
mybatis-plus: configuration: log-impl: ${mybatis-plus-log-impl}
${mybatis-plus-log-impl} Different values can be achieved.
The above is the detailed content of How to configure mybatisplus to enable printing of sql logs under springboot. For more information, please follow other related articles on the PHP Chinese website!