I want to log an error(with log4j 2) with some dynamic parameters that will provide better understanding what went wrong and I faced the problem that there is no method like:
void error(String message, Throwable t);
with parameters support.
In my code I want both exception and the parameters to fill {} in the message:
try {
//...
} catch (Exception e) {
LOGGER.error("Error removing data for account {}", accountId, e);
}
Is there a better way to implement it rather than using it like this?
LOGGER.error("Error removing token for account " + accountId, e);
e.message
ande.stacktrace
as additional parameters, but it is not the best idea. – CheekywithCause
). It's developed by Google, but it's still in alpha stage, unfortunately. – Telecast