SpringBoot + MyBatisSQL输出配置

fenqing 2019-06-30

  1. 指定MyBatis的日志实现为Slf4J
    application.yml文件

    mybatis:
      type-aliases-package: com.contract.housekeeper.dao.entity
      mapper-locations: classpath*:com/contract/housekeeper/dao/mapping/*.xml
      configuration:
        log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl

    log-impl属性种指定了Slf4j的日志实现

  2. 配置Mapper包输出级别为DEBUG
    application.yml文件

    logging:
      level:
        root: INFO
        com.exmple.mapper: DEBUG
      file: "D:/demo.log"
    #  config: classpath:logback-spring.xml

    root或mapper包指定为DEBUG




MyBatis的logImpl可选值有:

Log4j2LoggerImpl (org.apache.ibatis.logging.log4j2)
StdOutImpl (org.apache.ibatis.logging.stdout)
Jdk14LoggingImpl (org.apache.ibatis.logging.jdk14)
Slf4jImpl (org.apache.ibatis.logging.slf4j)
Slf4jLocationAwareLoggerImpl (org.apache.ibatis.logging.slf4j)
NoLoggingImpl (org.apache.ibatis.logging.nologging)
Slf4jLoggerImpl (org.apache.ibatis.logging.slf4j)
JakartaCommonsLoggingImpl (org.apache.ibatis.logging.commons)
Log4jImpl (org.apache.ibatis.logging.log4j)
Log4j2Impl (org.apache.ibatis.logging.log4j2)
Log4j2AbstractLoggerImpl (org.apache.ibatis.logging.log4j2)

相关推荐

lionelf / 0评论 2020-07-28