I want to implement an automatic exception logging service which collects all exceptions/errors that are thrown all over an application. The most elegant way would be to tap into either "throw" or the actual instantiation of the Throwable.
After several hours of research I came to following conclusions:
- Somehow "tap into" "throw" is not possible
- Inject code with Instrumentation (or cglib) could solve the problem
- Extend the class loader and override the newInstance method could solve the problem
So far I think that option 2 would be the best choice but I fear that I am probably missing a much easier solution.