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、啓動項目,訪問接口,測試日誌效果