If any exception occurs in the code, we have logged the exception using the logback logger. While logging we have directly passed the exception object e to the error method.
The exception which has been thrown from a third party jar contains sensitive information like username and password. Currently, we have the username and password as the private field in the code. But it does not seem appropriate to check for check log message do string comparison and then log.
As the exception is thrown by the third party API, fixed pattern for the exception is not known. That's why we are not able to use the %replace.
What is a good way to mask the sensitive data in the exception?