An excellent article which should be part of the coding rules of any Java project.
But I'd like to comment further on the log-and-throw. While generally speaking I do agree that a thrown exception should not be logged, there's a practical exception.
Consider a distributed application with Clients and Servers. The Client objects are deployed on different container (and hosts) than the Server objects, so they basically log to different files (and possibly with different settings).
If you only throw, the exception would be caught by Client objects and only logged to Client hosts. With an application which is currently in production and in mantaince mode, I often receive logs attached to incident reports from Server objects, while reporting from Clients objects is often incomplete (they are managed by different operators). In the end, if I didn't log also in Server objects, I'd completely lose exception information. |