在yml配置文件中,配置mybatis時,一般有如下配置
mybatis: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl map-underscore-to-camel-case: true typeAliasesPackage: XXXX mapper-locations: classpath*:**/xml/*Mapper.xml
log-impl指定的值爲org.apache.ibatis.logging.Log接口的某個實現類,是設置打印mybatis的日誌實現,
如果配置爲org.apache.ibatis.logging.stdout.StdOutImpl就只會在控制檯窗口打印,不會記錄到日誌文件。如果需要保存打印的SQL到文件就不能設置爲StdOutImpl,可以設置爲Slf4jImpl,也可以不設置。然後對應接口所在包設置logback對應包的日誌等級
# 日誌配置
logging:
level:
com.XXX: debug
org.springframework: warn
org.apache.ibatis.logging: debug
這樣就可以把mybatis的打印內容,保存到文件中了。