乐趣区

SpringBoot + MyBatisSQL输出配置

指定 MyBatis 的日志实现为 Slf4Japplication.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 的日志实现

配置 Mapper 包输出级别为 DEBUGapplication.yml 文件
logging:
level:
root: INFO
com.exmple.mapper: DEBUG
file: “D:/demo.log”
# config: classpath:logback-spring.xml
root 或 mapper 包指定为 DEBUG

Tips: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)

退出移动版