Snippets: Java: Spring: Log Feign Request

 20th August 2020 at 2:19pm

在 Spring Boot 应用中,如果用了 FeignClient 来描述远端接口,可以在 application.yml 或其他等同作用的配置文件中,加入下面的配置来使 Feign 发起的请求都打印在日志中:

feign:
  client:
    config:
      default:
        loggerLevel: basic

loggerLevel

  • NONE, No logging (DEFAULT).
  • BASIC, Log only the request method and URL and the response status code and execution time.
  • HEADERS, Log the basic information along with request and response headers.
  • FULL, Log the headers, body, and metadata for both requests and responses.

把相应的大写改成小写即可。

参考