方法一:
1、创建Feign的配置文件,并在其中设置日志等级
package com.data.platform.web;
import feign.Logger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class OpenFeignLogConfig {
@Bean
Logger.Level feignLoggerLeave() {
return Logger.Level.FULL;
}
}
2、在FeignClient接口中指定此配置
package com.test.client;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @Author: lshiqiang
* @Date: 2018/7/6 9:32
*/
//这边注解既有@Service 又有 @FeignClient,主要是单体和分布式共同调用
//1,如果是单体的时候,只会有用@Services实现
//2,如果是分布式的时候,会用到@FeignClient feigin的调用
//3,接口方法上面的注解是 由于调研服务的路径和调研的方法
@FeignClient(name= "test-manager-v1", value = "test-manager-v1" configuration = OpenFeignLogConfig.class)
public interface TestManagerClient {}
3、配置文件开启日志记录
如果是logback.xml
<!--openFeign日志打印-->
<logger name="com.test.client" level="DEBUG"/>
方法二:
在application.yml种加入如下配置
feign.client.config.test-manager-v1.loggerLevel : full
在logback.xml中配置
<!--openFeign日志打印-->
<logger name="com.test.client" level="DEBUG"/>