【轉載】Spring Cloud Gateway排錯、除錯技巧總結
阿新 • • 發佈:2020-08-26
http://www.imooc.com/article/290824
本文總結Spring Cloud Gateway的排錯、除錯技巧。歡迎留言補充!
第一式:Actuator監控端點
藉助Actuator的監控端點,可分析全域性過濾器、過濾器工廠、路由詳情。詳見:Spring Cloud Gateway監控
第二式:日誌
加日誌,按需將如下包的日誌級別設定成debug
或trace
,總有一款對你有用。
org.springframework.cloud.gateway
org.springframework.http.server.reactive
org.springframework.web.reactive
org.springframework.boot.autoconfigure.web
reactor.netty
redisratelimiter
配置示例:
logging:
level:
org.springframework.cloud.gateway: trace
第三式:Wiretap【從Greenwich SR3及更高版本才會支援】
Reactor NettyHttpClient
以及HttpServer
可啟用Wiretap
。將reactor.netty
包設定成debug
或trace
,然後設定如下屬性:
spring.cloud.gateway.httpserver.wiretap=true
spring.cloud.gateway.httpclient.wiretap=true
分別開啟HttpServer及HttpClient的Wiretap。
然後,就可以分析日誌啦。
TIPS
- 相關Issue:https://github.com/spring-cloud/spring-cloud-gateway/issues/1194
- wiretap其實是Reactor Netty的概念,作用是,列印對端之間的流量詳情,相關文件:
本文首發
http://www.itmuch.com/spring-cloud-gateway/spring-cloud-gateway-debug/