We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
As discussed, it would be good to be able to customise the formatting of the request/response body before logging.
My particular use case is the need to obfuscate passwords sent in the request before writing to the log.
As a very first stab at this, how about allowing the LoggingInterceptor to be constructed with a LoggingFormatter, something like:
LoggingInterceptor
LoggingFormatter
public interface LoggingFormatter { String formatRequest(HttpRequest request, byte[] body); String formatResponse(ClientHttpResponse response); }
with a default implementation:
public class DefaultLoggingFormatter implements LoggingFormatter { @Override public String formatRequest(HttpRequest request, byte[] body) { // tmpl method to generate log line from URL, method, body... } @Override public String formatResponse(ClientHttpResponse response) { // tmpl method to generate log line from response status, body... } protected String formatBody(byte[] body, Charset charset) { return new String(body, charset); } protected Charset getCharset(HttpMessage message) { // ... } }
This would support resolution of e.g. #2 as well. Then perhaps #1 via introducing something like a supports(MediaType) method to the formatter?
supports(MediaType)
What do you think? Happy to prepare a PR following your feedback.
The text was updated successfully, but these errors were encountered:
I like it a lot! It certainly provides a good place to address the other issues as you say. Thanks Ryan 👍
P.S. A pedant would say LogFormatter as it's not actually doing the logging.
LogFormatter
Sorry, something went wrong.
Document configuring a different log formatter, #6
3873896
Thanks for the PR!
Do you know when this version will be published to Maven Central?
@jmart1 I've just released 2.0.0, so it should be there shortly. Thanks for the reminder!
Yup its there. Thank you!!!
markhobson
No branches or pull requests
As discussed, it would be good to be able to customise the formatting of the request/response body before logging.
My particular use case is the need to obfuscate passwords sent in the request before writing to the log.
As a very first stab at this, how about allowing the
LoggingInterceptor
to be constructed with aLoggingFormatter
, something like:with a default implementation:
This would support resolution of e.g. #2 as well. Then perhaps #1 via introducing something like a
supports(MediaType)
method to the formatter?What do you think? Happy to prepare a PR following your feedback.
The text was updated successfully, but these errors were encountered: