使用Spring Cloud Feign 日志查看请求响应

在使用微服务时,常常会用feign做客户端去调用别的微服务,但是在日志中很难查看到具体的请求和响应。因此,需要把feign默认的日志打开。

日志设置

  • 创建feign配置类

@Configuration
public class FeignLogConfiguration {

    @Bean
    Logger.Level feignLoggerLevel() {

        return Logger.Level.FULL;

    }
}
  • 其中Logger.Level是枚举类

  • application.properties或者application.yml文件中设置Feign客户端的日志级别----->可以看到feign客户端的请求响应
logging.level.com.wugui.spring.cloud.weather.Service:debug

  • 其中com.wugui.spring.cloud.weather.Service为feign client接口所在包

日志查看

猜你喜欢

转载自www.cnblogs.com/peterpoker/p/9563478.html