6

各位是怎么打印封装第三方 api 的出入参日志的呢

 2 years ago
source link: https://www.v2ex.com/t/805384
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Java

各位是怎么打印封装第三方 api 的出入参日志的呢

  zhongpingjing · 1 天前 · 772 次点击
之前是每个封装的 http 请求的方法都手动 log.info 去打印,感觉模版代码有点多

现在改用 RestTemplate 的拦截器机制,在拦截器里打印 request 跟 response,但是也发现有个问题,就是 response 的流被消费一次后,后面去获取 response 就会是空,通过复制一遍流(和使用 BufferingClientHttpRequestFactory )解决了。但是这样又有一个问题,这样会有性能损失,而且大 response 复制一遍会占用很多内存吧。

想请教各位平时是怎么打印第三方 api 的出入参的

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK