OpenFeign的日志級別有:
NONE: 默認的,不顯示任何日志
BASIC: 僅記錄請求方法、URL、響應狀態碼以及執行時間
HEADERS:除了BASIC 中自定義的信息外,還有請求和響應的信息頭
FULL: 除了HEADERS中定義的信息外, 還有請求和響應的正文以及元數據。
下面咱們來進行日志功能配置:
1、先構建日志配置類
package com.king.springcloud.config; import feign.Logger; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * created by king on 2020/4/16 11:16 上午 */ @Configuration public class OpenFeignLogConfig { @Bean Logger.Level feignLoggerLeave(){ return Logger.Level.FULL; } }
2、構建yml,配置那個接口需要以什么日志級別監控
logging:
level:
# feign日志以什么級別監控哪個接口
com.king.springcloud.service.OrderFeignService: debug
3、啟動項目,訪問接口,測試日志效果