Home > Java > javaTutorial > How to configure mybatisplus to enable printing of sql logs under springboot

How to configure mybatisplus to enable printing of sql logs under springboot

WBOY
Release: 2023-05-17 15:34:13
forward
8805 people have browsed it

The following three configurations are required

1: Set the log level under the mybatisplus package to DEBUG;

logging:
  level:
    com:
      baomidou:
        mybatisplus: DEBUG
Copy after login

2: Set the project mapper directory (dao package path) The log level is DEBUG;

logging:
  level:
    com:
      xxx: 
        xxx
         xxx: DEBUG
Copy after login

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
Copy after login

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
Copy after login

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}
Copy after login

${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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template