1. 程式人生 > 實用技巧 >【轉載】Spring Cloud Gateway排錯、除錯技巧總結

【轉載】Spring Cloud Gateway排錯、除錯技巧總結

http://www.imooc.com/article/290824

本文總結Spring Cloud Gateway的排錯、除錯技巧。歡迎留言補充!

第一式:Actuator監控端點

藉助Actuator的監控端點,可分析全域性過濾器、過濾器工廠、路由詳情。詳見:Spring Cloud Gateway監控

第二式:日誌

加日誌,按需將如下包的日誌級別設定成debugtrace,總有一款對你有用。

  • 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包設定成debugtrace,然後設定如下屬性:

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

分別開啟HttpServer及HttpClient的Wiretap。

然後,就可以分析日誌啦。

TIPS

本文首發

http://www.itmuch.com/spring-cloud-gateway/spring-cloud-gateway-debug/