buguge - Keep it simple,stupid

知识就是力量,但更重要的,是运用知识的能力why buguge?

导航

SpringBoot日志打印程序执行的SQL语句

springboot默认使用logback来记录日志。

属性:logging.level。见 spring-boot-*.RELEASE.jar里org.springframework.boot.context.logging.LoggingApplicationListener#LOGGING_LEVEL

 

 


在application.yml里添加如下配置即可

logging:
  level:
    com.emaxcard.boss.modules: debug
    com.emaxcard.boss.portal: debug

 或者在application.propertities里添加配置

logging.level.com.emaxcard.boss.modules=debug
logging.level.com.emaxcard.boss.portal=debug


注意:
1)mapper文件在指定的package下
2)指定了package之后,这个package下所有的class文件的日志级别都是debug。即,这些class文件里的debug日志会打印到日志文件里。
3)package路径注意书写正确。

 

log示例:

2021-12-17 18:10:07.009 [5ffff3f3f7ed43f294b7b4d3661c97fb] [OrderDetailServiceImpl_list1639735807008] DEBUG c.e.b.m.settlement.provider.OrderDetailServiceImpl:485 - [结算明细]-生成QueryWrapper请求参数={"encrypt":true,"taskId":1630922570528780}
2021-12-17 18:10:07.014 [5ffff3f3f7ed43f294b7b4d3661c97fb] [OrderDetailServiceImpl_list1639735807008] DEBUG c.e.b.m.s.mapper.OrderDetailMapper.selectList:143 - ==>  Preparing: SELECT * FROM emax_order_detail WHERE task_id = ? ORDER BY create_time DESC 
2021-12-17 18:10:07.015 [5ffff3f3f7ed43f294b7b4d3661c97fb] [OrderDetailServiceImpl_list1639735807008] DEBUG c.e.b.m.s.mapper.OrderDetailMapper.selectList:143 - ==> Parameters: 1630922570528780(Long)
2021-12-17 18:10:07.049 [5ffff3f3f7ed43f294b7b4d3661c97fb] [OrderDetailServiceImpl_list1639735807008] DEBUG c.e.b.m.s.mapper.OrderDetailMapper.selectList:143 - <==      Total: 12
2021-12-17 18:10:07.052 [5ffff3f3f7ed43f294b7b4d3661c97fb] [OrderDetailServiceImpl_list1639735807008] INFO  c.e.z.common.dubbothread.DubboThreadNameAspect:96 - 接口响应结果:{"code":200,"message":"成功","result":[{"bankAccountNo":"62148****1482783","userIdcardNo":"130682********0412","userName":"王力宏","userPhone":"1830153****","verifyStatus":"VERIFY_SUCCESS","workTyp...
2021-12-17 18:10:07.053 [5ffff3f3f7ed43f294b7b4d3661c97fb] [OrderDetailServiceImpl_list1639735807008] INFO  c.e.z.common.dubbothread.DubboThreadNameAspect:147 - OrderDetailServiceImpl_list--duration=执行耗时=45ms

 

 

 

 

ref:

springboot日志配置

Spring boot mybatis 打印SQL语句

slf4J输出mybatis日志的方法(非stdout方式)

posted on 2021-12-18 19:30  buguge  阅读(2506)  评论(0编辑  收藏  举报