Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging request and response json payloads with Hystrix Feign

I am using Hystrix Feign with Spring Encoder. I want to log exact request (Json) payload that goes out with each request and also the response. How can I do that?

like image 563
Vikrant Kandgaonkar Avatar asked Mar 16 '17 12:03

Vikrant Kandgaonkar


People also ask

How do you log feign client request and response?

If you are using spring-cloud-starter-feign 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.

How do I enable feign logging?

Feign client logging helps us to have a better view of the requests that have been made. To enable logging, we need to set the Spring Boot logging level to DEBUG for the class or package that contains our feign client in the application. properties file. Next, we need to set the logging level for the feign client.

Can we use feign client without Eureka?

Yes you can use Feign without Ribbon, All you need to do is specify the base url in your Feign Java interface class.

How do you pass a body request in feign client?

Passing arguments through the request body of HTTP requests This will instruct Feign to issue a PUT call to the service, adding the query paramter “iterations” to the request URL and the string value in the HTTP request body. String postToServerOnSecondService(String value, @RequestParam int id);


1 Answers

When you define your feign configuration, you have to set the feign logger level, according to the feign logger class, you have 4 possible values, so probably you want to use Logger.Level.FULL.

Hope this help you.

like image 172
psantamaria Avatar answered Sep 29 '22 07:09

psantamaria