I am using following configuration to enable logging for API calls made using feign
#Feign properties
feign:
client:
config:
default:
loggerLevel: full
My application is making calls to 3 APIs and feign is logging request and response JSON correctly for all the 3 APIs . I want to disable this logging for one of the API. Can you please let know on the necessary configuration. Thanx in advance
If you have 3 different feign clients for 3 APIs, then you can simply override logging level in this way (assuming that your feign client is called "feignClient2"):
#Feign properties
feign:
client:
config:
default:
loggerLevel: full
feignClient2:
loggerLevel: none
But if you have one feign client for 3 endpoints, then the task becomes more complicated. You can inherit feign logger class (or any of its children classes, f.e. Slf4jLogger, if you use it now) and override its logRequest
and logAndRebufferResponse
methods to not log anything for specific endpoint (you can get the required information from request
and response
method parameters respectively). Then add FeignLoggerFactory
bean with your own logger:
@Bean
public FeignLoggerFactory feignLoggerFactory() {
return new DefaultFeignLoggerFactory(new CustomLogger());
}
It will override the default FeignLoggerFactory
from FeignClientsConfiguration.
In summary, I would recommend you to use the first option (with separate feign client). But if you choose the second one, I could help you to do it if you provide the example of your code.