mybatis-plus日志输出sql配置(控制台能输出sql日志没有sql问题)

看下spring boot配置文件中的mybatis部分

mybatis-plus:
  global-config:
    banner: false
    db-config:
      #主键类型  0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
      id-type: AUTO
      # 默认数据库表下划线命名
      table-underline: true
  configuration:
    log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
    #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    call-setters-on-nulls: true
    map-underscore-to-camel-case: true
    use-generated-keys: true
    default-fetch-size: 100
    default-statement-timeout: 30
  mapper-locations: classpath*:/**/**Mapper.xml
  tenantIgnoreTable: ac_book,ac_book_item,ac_dict,ac_family,ac_friend,zhifou_application

#日志级别
logging:
  level:
    root: info
    com.xxx: debug

一般配置debug级别日志,基本日志都能输出了,之前配置,这个是标准的输出,控制台正常输出,但是不会写到日志文件中,所以一旦上传测试或生产,自动过滤sql部分日志

log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

但是我们也希望在测试环境也能看

改成如下配置

log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl

另外日志级别改为debug,可以直接

logging:
  level:
    root: debug

就整体都是debug了

如果需要局部控制,可以配置多个level

logging:
  level:
    root: info
    com.xxx: debug
    com.aaa: debug

只要是com.xxxx,com.aaa下的日志输出均是debug

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容