feign icon indicating copy to clipboard operation
feign copied to clipboard

Log HTTP body, not headers

Open leaqui opened this issue 2 years ago • 2 comments

It could be useful to allow logging of HTTP body but not headers.

In some cases, headers contains restricted / confidential information such as usernames, passwords, tokens, so you don't want to write them to logs. Whilst HTTP body could contribute useful information.

Actually feign.Logger doesn't have a feign.Logger.Level allowing to configure logging of HTTP body but not headers.

To do that you could create feign.Logger subclass, and rewrite logRequest and logAndRebufferResponse methods.

leaqui avatar Dec 19 '22 14:12 leaqui

Hi!

Try to use https://github.com/OpenFeign/feign/blob/1c5c6e1e701742dc58ed805799ec59921320624d/core/src/main/java/feign/Logger.java#L52 and https://github.com/OpenFeign/feign/blob/1c5c6e1e701742dc58ed805799ec59921320624d/core/src/main/java/feign/Logger.java#L62 to hide sensitive data.

vitalijr2 avatar Jan 26 '23 20:01 vitalijr2

Thanks @radio-rogal for reply.

Yes, this alternative is useful for not logging some headers (or all of them), but it loops through all headers and you must create a feign.Logger subclass to specify this.

It would be great to have a feign.Logger.Level to log body but not headers.

leaqui avatar Jan 27 '23 11:01 leaqui