1、说明
springboot
集成mybatis
项目中,mybatis默认日志输出为debug
级别。 打印日志如下,大量的语句参数信息,当在生产环境下,如果大量日志会导致排查问题困难(日志并发量大,交替严重)。这里我们设置日志级别。
[2021-08-26 11:22:07.296] [level: DEBUG] [Thread: http-nio-8081-exec-1] [ Class:com.myexp.mapper.SysAdminDepInfoMapper.selectByBelongDistrictCode >> Method: debug:159 ]
DEBUG:<== Total: 1
[2021-08-26 11:22:07.301] [level: DEBUG] [Thread: http-nio-8081-exec-1] [ Class:com.myexp.mapper.MyexpIndexPageMapper.selectByExample >> Method: debug:159 ]
DEBUG:==> Preparing: select id, version, district_id, brand_code, page_name, background_color, background_image, has_share_title, page_remarks, share_title,has_share_image, share_image, status, create_time, update_time, delete_time from myexp_index_page WHERE ( district_id = ? and brand_code = ? and status = ? )
[2021-08-26 11:22:07.302] [level: DEBUG] [Thread: http-nio-8081-exec-1] [ Class:com.myexp.mapper.MyexpIndexPageMapper.selectByExample >> Method: debug:159 ]
DEBUG:==> Parameters: MYEXP_DISTRICT_bcff121250e545f1abd7a440b4e30fca(String), yysports(String), 1(Integer)
[2021-08-26 11:22:07.304] [level: DEBUG] [Thread: http-nio-8081-exec-1] [ Class:com.myexp.mapper.MyexpIndexPageMapper.selectByExample >> Method: debug:159 ]
DEBUG:<== Total: 1
[2021-08-26 11:22:07.305] [level: DEBUG] [Thread: http-nio-8081-exec-1] [ Class:com.myexp.mapper.MyexpIndexPageFloorMapper.selectByExampleWithBLOBs >> Method: debug:159 ]
DEBUG:==> Preparing: select id, index_id, floor_type, sort, create_time, update_time , floor_details from myexp_index_page_floor WHERE ( index_id = ? )
[2021-08-26 11:22:07.306] [level: DEBUG] [Thread: http-nio-8081-exec-1] [ Class:com.myexp.mapper.MyexpIndexPageFloorMapper.selectByExampleWithBLOBs >> Method: debug:159 ]
DEBUG:==> Parameters: 55(Integer)
[2021-08-26 11:22:07.310] [level: DEBUG] [Thread: http-nio-8081-exec-1] [ Class:com.myexp.mapper.MyexpIndexPageFloorMapper.selectByExampleWithBLOBs >> Method: debug:159 ]
DEBUG:<== Total: 8
...
2、mybatis设置日志级别
- 方式一:改配置文件日志级别为
info
springboot整合mybatis可以通过配置文件修改级别,这里com.myexp.mapp.*
是mybatis mapper文件所在目录。
logging:
level:
com.myexp.mapper.*: info
- 方式二:通过
logback
配置来设置输出级别
当前springboot流行框架使用了logback作为日志工具。可设置
<logger name="com.myexp.mapper.*" level="DEBUG" additivity="false">
网友评论