How can I detect when an Exception's been thrown globally in Java?

后端 未结 10 473
自闭症患者
自闭症患者 2020-11-30 02:30

How can I detect when an Exception has been thrown anywhere in my application?

I\'m try to auto-magically send myself an email whenever an exception is thrown anywhe

10条回答
  •  鱼传尺愫
    2020-11-30 03:07

    In this case I think your best bet might be to write a custom classloader to handle all classloading in your application, and whenever an exception class is requested you return a class that wraps the requested exception class. This wrapper calls through to the wrapped exception but also logs the exception event.

提交回复
热议问题