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
Add toString hook for GenericMessage to let end-users obfuscate non-public information in logs #24727
Comments
We something similar in One concern is avoiding per message object creation, which could certainly happen with a lambda friendly method signature. Another thought is the need to customize the message depending on the context such as a log level given a specific log category, or specific location in the code. It seems that such a component wouldn't have all the context to make a decision and that the framework should still be able to say, format with all details, or format something more minimal. Another alternative would be to applying formatting externally wherever messages are logged which is of course more work. Yet another idea is the ability to specify sensitive headers on GenericMessage and excluding those from toString. |
Thanks, @rstoyanchev , for feedback! Well, I know that we have those Also, as you pointed that out, it really becomes unreachable goal to make a decision on the log level without know a target application context. You concern about "per message object creation" is slightly not critical since our idea is to allow end-user to configure an We may also introduce some Another option, if you still against I'm really up to disabling logging for the framework and let target project to decide what and how to log... Thanks |
Another problem is that most exceptions are Surely we don't want to suppress logging of exceptions? |
I didn't mean to suggest that I'm not against doing something here, but a This can then be used to log a |
Thanks, @rstoyanchev , for your discernment! I don't the whole tool yet (that We probably can discuss implementation details later, when we have already something in hands. |
i think the original proposal and my suggestion aren't necessarily mutually exclusive. Such a formatter could be set on, and obtained from a Message, and it could be integrated into the |
See spring-projects/spring-integration#3222 for more info.
An idea to have something like
GenericMessage .setToStringFunction(Function<Message<?>, String>)
which is going to be called from theMessage.toString()
.So, end-user can provide any possible way for presenting message in logs.
Thanks
The text was updated successfully, but these errors were encountered: