Description
Feign currently has it's own implementation for logging through the Logger class. This provides informative messages and configurable levels of detail about requests, from just the request method/URL & response, to including the headers, or even the entire body. This configuration applies to all requests for the client.
Feign also provides feign-slf4j
which will emit those log messages via SLF4J at the debug
level.
First, the slf4j integration doesn't provide any output in environments where SLF4J is set to any level less than debug
(most production environments I've interacted with only log info
and above).
Second, the logging is all or nothing—there is no way to see more detail for requests that result in an error.
Logging in Feign would be much more useful if it could provide output tailored to different log levels that SLF4J defines, e.g. headers at debug
, request method & URL at info
, retries at warn
, and failures at error
. This would allow users existing SLF4J configurations to tailor Feign's output as appropriate for the environment.
I do not think this can be accomplished in the existing framework provided by Logger
, as it does not know what level the underlying logging implementation is configured for nor does it provide logging level information to the underlying implementation along with messages. I propose adding slf4j-api
to feign-core
and using it for logging throughout Feign.
I realize that this is a big request, as feign-core
currently has no required dependencies, but SLF4J is incredibly widely used and its addition would prove a great utility for Feign deployments in production environments.