SpringCloud增加Feign日誌打印

一、FeignConfiguration.class

package com.xiaohang.socialcard.pre.feign;

import feign.Logger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FeignConfiguration {
    @Bean
    Logger.Level feignLoggerLevel() {
        //這裏記錄所有,根據實際情況選擇合適的日誌level
        return Logger.Level.FULL;
    }
}

二、Application.yml配置需要打印Feign請求日誌的API接口

logging.level.com.xiaohang.socialcard.pre.feign.ChangShaApi: debug

三、打印示例:

2019-07-05 17:32:42.478 DEBUG 99302 --- [ngsha-payment-3] c.x.socialcard.pre.feign.ChangShaApi     : [ChangShaApi#getToken] ---> GET http://xx.xx.xx.xx:xxxx/openInter/getToken?
......
2019-07-05 17:32:42.566 DEBUG 99302 --- [ngsha-payment-3] c.x.socialcard.pre.feign.ChangShaApi     : [ChangShaApi#getToken] <--- END HTTP (454-byte body)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章