I'm kinda late from here but let me try to help fellow people finding this thread.
There are two things we have to distinguish. Feign logging when using plain Feign and when using it with Spring Cloud OpenFeign.
With plain Feign, you gotta do a few things do make things work:
- You have to set the log level for your client
- You have to configure the appropriate log adapter of your choice
- You have to set the
feign
logger to DEBUG
Let me show you how to do it:
Feign.builder()
.logLevel(Logger.Level.FULL)
.logger(new Slf4jLogger())
.target(MyClient.class, "http://localhost:8081");
In this particular case, I'm using SLF4J as the logging adapter. This configuration took care of step 1 and 2.
Now let's configure the logger. And don't forget, this may vary depending on your logging setup, I'll show you one with Spring Boot:
application.properties
:
logging.level.feign=DEBUG
But this could be done with plain Logback in your logback.xml
, log4j, whatever logging system you have. The only important thing is to configure the feign
named logger to DEBUG
.
This is due to the fact that the Feign library logs everything with the feign
logger and not with the class name of the target clients.
With Spring Cloud OpenFeign, it changes a little bit because Spring uses the client's class name to set up the logger.
For this case, we only have to do 2 things - if you're using the @FeignClient
annotation.
- Configure the log level for the clients
- Configure the appropriate client logger to
DEBUG
The first can be done this way:
@Configuration
public class FeignConfiguration {
@Bean
public Logger.Level loggerLevel() {
return Logger.Level.FULL;
}
}
This will configure the log level for all the Feign clients unless you use a specific configuration in the @FeignClient
annotation.
Second thing, enable DEBUG
logging for the client's class/package.
application.properties
:
logging.level.com.example.MyClient=DEBUG
If you're struggling with Feign configuration, you might wanna take a look at my articles or my course.
Cheers.
logging.level.com.mycompany.admintool.external.persons.resource.CustomerResource: DEBUG
– Borneol