[英]How can I log all REST calls?
在調試器中,我可以看到
JerseyWebTarget { http://host.com/service/method }
我了解了它如何構建參數,然后執行service.method(parms)調用。 我可以以某種方式記錄呼叫,以便獲得完整的URL,例如
http://host.com/service/method?id=5
還有更復雜的參數,例如我傳輸到服務的大型JSON文件?
內置彈簧為此提供了一個過濾器。 將下面的bean添加到配置文件中。
@Bean
public CommonsRequestLoggingFilter requestLoggingFilter() {
CommonsRequestLoggingFilter loggingFilter = new CommonsRequestLoggingFilter();
loggingFilter.setIncludeClientInfo(true);
loggingFilter.setIncludeQueryString(true);
loggingFilter.setIncludePayload(true);
return loggingFilter;
}
還要將org.springframework.web.filter.CommonsRequestLoggingFilter
日志級別更改為DEBUG
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.