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:
当看到一些不好的代码时,会发现我还算优秀;当看到优秀的代码时,也才意识到持续学习的重要!--buguge
本文来自博客园,转载请注明原文链接:https://www.cnblogs.com/buguge/p/15705793.html