springboot集成CAT日志监控,加上更多sql驱动的监控

本文介绍了如何在SpringBoot项目中集成CAT日志监控系统,包括添加客户端依赖、配置过滤器、使用AOP进行低侵入式监控,以及详细步骤来监控SQL执行情况,以实现更精细化的应用监控。
摘要由CSDN通过智能技术生成

首先需要搭建CAT的服务端,需要配置对应客户端的配置,这里就不展开说明了,感兴趣的可以查看我之前的博客

1.第一步,引入CAT的客户端依赖,以及springboot的依赖

 


  <dependencies>
    <!-- cat的客户端的依赖 -->
    <dependency>
      <groupId>com.dianping.cat</groupId>
      <artifactId>cat-client</artifactId>
      <version>3.0.0</version>
    </dependency>

    <!-- 如果启动服务报错的话,则需要引入这个gson -->
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.8.5</version>
    </dependency>


    <!-- springboot 依赖 -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
      <version>2.2.5.RELEASE</version>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <version>2.2.5.RELEASE</version>
    </dependency>

    <!-- aop 的依赖 -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-aop</artifactId>
      <version>2.2.5.RELEASE</version>
    </dependency>

    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>1.9.4</version>
    </dependency>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
      <version>1.9.4</version>
    </dependency>

   <!-- mybatis plus -->
   <dependency>
      <groupId>com.baomidou</groupId>
      <artifactId>mybatis-plus-boot-starter</artifactId>
      <version>3.4.1</version>
    </dependency>

    <dependency>
      <groupId>com.baomidou</groupId>
      <artifactId>mybatis-plus-generator</artifactId>
      <version>3.4.1</version>
    </dependency>

    <!-- mysql 驱动 -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.16</version>
    </dependency>

    <!-- 阿里的连接池 -->
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid</artifactId>
      <version>1.1.21</version>
    </dependency>

    <!-- json 工具 -->
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>fastjson</artifactId>
      <version>1.2.70</version>
    </dependency>

  </dependencies>

  2.集成CAT,添加CAT的过滤器的使用,在任意springboot可以扫描到的地方添加该类,这样CAT就算集成了

 @Configuration
	public class CatFilterConfigure {
	    @Bean
	    public FilterRegistrationBean catFilter() {
	        FilterRegistrationBean registration = new FilterRegistrationBean();
	        CatFilter filter = new CatFilter();
	        registration.setFilter(filter);
	        registration.addUrlPatterns("/*");
	        registration.se
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值