查看原文
其他

Spring Cloud Gateway排错、调试技巧总结

itmuch IT牧场 2021-08-10

点击上方"IT牧场",选择"设为星标"技术干货每日送达!

本文总结Spring Cloud Gateway的排错、调试技巧。欢迎留言补充!

第一式:Actuator监控端点

借助Actuator的监控端点,可分析全局过滤器、过滤器工厂、路由详情。详见:Spring Cloud Gateway监控

第二式:日志

加日志,按需将如下包的日志级别设置成 debug 或 trace ,总有一款对你有用。

org.springframework.cloud.gatewayorg.springframework.http.server.reactiveorg.springframework.web.reactiveorg.springframework.boot.autoconfigure.webreactor.nettyredisratelimiter

配置示例:

logging: level: org.springframework.cloud.gateway: trace

第三式:Wiretap【从Greenwich SR3及更高版本才会支持】

Reactor Netty HttpClient 以及 HttpServer 可启用 Wiretap 。将reactor.netty 包设置成 debug 或 trace ,然后设置如下属性:

spring.cloud.gateway.httpserver.wiretap=truespring.cloud.gateway.httpclient.wiretap=true

分别开启HttpServer及HttpClient的Wiretap。

然后,就可以分析日志啦。

TIPS

•相关Issue: https://github.com/spring-cloud/spring-cloud-gateway/issues/1194[1]•wiretap其实是Reactor Netty的概念,作用是,打印对端之间的流量详情,相关文档:

•HttpClient的Wire Logger[2]•HttpServer的Wire Logger[3]


干货分享

最近将个人学习笔记整理成册,使用PDF分享。关注我,回复如下代码,即可获得百度盘地址,无套路领取!

•001:《Java并发与高并发解决方案》学习笔记;•002:《深入JVM内核——原理、诊断与优化》学习笔记;•003:《Java面试宝典》•004:《Docker开源书》•005:《Kubernetes开源书》•006:《DDD速成(领域驱动设计速成)》•007:全部•008:加技术讨论群

近期热文

Spring Boot 2.0 迁移指南阿里巴巴资深技术专家雷卷:值得开发者关注的 Java 8 后时代的语言特性完美整合Spring Cloud与异构微服务的框架!Spring Cloud Wii开源啦!每天用SpringBoot,还不懂RESTful API返回统一数据格式是怎么实现的?实用 Chrome 插件汇总(42个哟!)盘点10个最难回答的Java面试题

References

[1]https://github.com/spring-cloud/spring-cloud-gateway/issues/1194
[2] HttpClient的Wire Logger: https://projectreactor.io/docs/netty/milestone/reference/index.html#_wire_logger_2
[3] HttpServer的Wire Logger: https://projectreactor.io/docs/netty/milestone/reference/index.html#_wire_logger


想知道更多?长按/扫码关注我吧↓↓↓>>>技术讨论群<<<喜欢就点个"在看"呗^_^


    您可能也对以下帖子感兴趣

    文章有问题?点此查看未经处理的缓存