• 使用springboot默认的日志系统logback打印Mybatis语句问题


    在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的打印内容,保存到文件中了。

    注意:如果在logback-spring.xml文件中通过下面的方式配置的时候:

        <springProfile name="dev,test,prod">
            <root level="info">
                <appender-ref ref="console"/>
                <appender-ref ref="logFile"/>
            </root>
        </springProfile>

    需要在yml配置文件中添加:

    spring:
      profiles:
        active: dev

    不然在控制台或者文件中是空白的

  • 相关阅读:
    mybatis中&gt;=和&lt;=的实现方式
    沙盒
    华硕 X201E 拆机
    延迟满足
    文本输入框自适应高度
    Qt实战之酷狗音乐
    协议栈处理中的conntrack HASH查找/Bloom过滤/CACHE查找/大包与小包/分层处理风格
    【processing】小代码3
    【processing】小代码2
    【processing】小代码
  • 原文地址:https://www.cnblogs.com/grasp/p/12354955.html
Copyright © 2020-2023  润新知