Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log HTTP body, not headers #1888

Open
leaqui opened this issue Dec 19, 2022 · 2 comments
Open

Log HTTP body, not headers #1888

leaqui opened this issue Dec 19, 2022 · 2 comments

Comments

@leaqui
Copy link

leaqui commented Dec 19, 2022

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.

@vitalijr2
Copy link
Collaborator

Hi!

Try to use

protected boolean shouldLogRequestHeader(String header) {
and
protected boolean shouldLogResponseHeader(String header) {
to hide sensitive data.

@leaqui
Copy link
Author

leaqui commented Jan 27, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants