Whats the best way to notify admin about new exceptions of the Java application?

exception, jakarta-ee, java, jms, struts2

Solution

I'd suggest using log4j, configured with an `SMTPAppender` listening to fatal logs. Then, just log a fatal level message (containing any useful information you can get) for any unhandled exception reaching your global try/catch block.

See also : What is the proper way to configure SMTPAppender in log4j?

Problem

My question is that whats the best way to keep track of the exceptions for the administrator of the application. (Notify administrator of the thrown exceptions for maintenance purposes). To users of the system, I believe should catch the exceptions and show an appropriate error message. To admin of the system, I suppose, best method is to have a messaging system to send details of each exception as a message to the receiver. Once receiver received a new error message persists it in the database or pings the admin an email with details of the exception. ``` try{ .... } catch(Exception e){ //what to do here? how to notify admin? } ```

Original source

Related problems