ppkarwasz commented on issue #3433: URL: https://github.com/apache/logging-log4j2/issues/3433#issuecomment-2726435795
> ``` > try > { > doThing(); > } > catch (ThingFailedException ex) > { > logger.error(ex); > throw new WhateverException(ex); // Maybe also this > } > ``` Try: ```java try { doThing(); } catch (ThingFailedException ex) { throw logger.throwing(new WhateverException(ex)); } ``` **Note**: this is an anti-pattern (cc/@rgoers), because you don't trust the caller to properly handle the exception, so you log it for auditing purposes. If the caller handles the exception properly, it will appear **twice** in the logs, but if he ignores the exception or only shows it to the user (that later denies it) you can easily prove you didn't hide the error. I understand the intention, I see it often and sometimes I use it myself (should I trust the frontend dev ❓ ), but it is **not** a best practice. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org