1、概念java
Feign的日志很是灵活,能够为指定的Feign客户端指定日志记录策略,每一个Feign客户端都会建立一个logger.spring
Feign的日志打印支队DEBUG级别做出响应。app
咱们能够为Feign客户端配置对应的Logger.Level对象,有如下值供选择。ide
NONE:不记录任何值测试
BASIC:仅记录请求方法、URL、响应状态及执行时间debug
HEADERS:记录BAISC级别的基础上,记录响应的请求和响应header日志
FULL:外加body和元数据对象
2、代码修改blog
修改movie服务接口
一、编写Feign配置类
import feign.Logger; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class FeignLogConfiguration { @Bean Logger.Level feignLoggerLevel(){ return Logger.Level.FULL; } }
二、修改feign接口,增长配置类
@FeignClient(name = "user",configuration = FeignLogConfiguration.class) public interface UserFeignClient { @RequestMapping(value = "/user/getUserInfo", method = RequestMethod.GET) Map findById(@RequestParam("userId") Integer userId); }
三、修改yml文件,设置日志级别为debug
logging: level: com.my.movie.service.feignService.UserFeignClient: DEBUG
3、测试
访问 http://localhost:8020/movie/findById/feign?userId=1
观察movie控制台,打印出以下信息