Logging

To see what a client sends and receives, set its logger-level above none. Each call is then logged under the logger feign.<Interface> at debug level, so that level must be on too.

Why

When a call fails, the first question is what was sent and what came back. The log answers it without a debugger or a proxy. Credentials in headers must not end up in log files, so their values are masked.

Example

spring.feign.client.config.catalog.logger-level=headers
spring.feign.client.config.default.sensitive-headers=X-Api-Key,X-Partner-Token
logging.level.feign=debug
---> GET https://api.neon.books/books/978-0
Accept: application/json
X-Api-Key: ***
<--- 200 OK (84 ms)
content-type: application/json

Levels

logger-level Logged
none Nothing; the default. Failed connections and retries are not logged either, as in Feign.
basic The method and URL of each request, the status and time of each response, failed connections (<--- ERROR ...), retries (---> RETRYING ...) and event-stream reconnects (---> RECONNECTING ...).
headers basic plus the request and response headers, with credentials masked.
full headers plus the bodies.

Set it per client (spring.feign.client.config.catalog.logger-level) or for all (...config.default.logger-level). The logger is feign.<Interface> (feign.CatalogClient), so logging.level.feign=debug turns them all on, and logging.level.feign.CatalogClient=debug one.

Masked headers

In the headers and full logs, the values of these headers are shown as *** (names in any case):

The URL is logged with its query, so a key sent as a query parameter shows. Send secrets as headers and name the ones the starter does not mask already. full logs bodies as they are: do not use it where bodies hold personal data.

In Spring (Java)

spring.cloud.openfeign.client.config.catalog.logger-level: headers
logging.level.com.example.CatalogClient: debug

The levels are Feign's. The logger is feign.<Interface>, not the interface's fully qualified name. Feign's logger masks nothing; here credentials and sensitive-headers (an addition) are masked.

See also