On Wednesday, December 11, 2013 5:55:34 PM UTC-5, RVic wrote:
> Is anyone aware of a public domain package that can email you on an error, include the stack trace or log, whenever an exception occurs? Thank you, RVic

Looking to send an email on exceptions that are caught, and a general one for those that are uncaught.

On Wednesday, December 11, 2013 5:55:34 PM UTC-5, RVic wrote:
> Is anyone aware of a public domain package that can email you on an error, include the stack trace or log, whenever an exception occurs? Thank you, RVic

I thought maybe there was a commons package to do all this relatively simply.

On 12/11/2013 6:13 PM, Eric Sosman wrote:
> On 12/11/2013 5:55 PM, RVic wrote:
>> Is anyone aware of a public domain package that can email you on an
>> error, include the stack trace or log, whenever an exception occurs?
>
> I think you'd have to modify the JVM itself to do this. But
> you wouldn't want to: If you got an E-mail for every exception
> thrown, you'd drown in E-mail.
>
> Presumably, what you really want is E-mail about "important"
> exceptions, and the hard part is clarifying what "important" means.
> Could you describe your use case in more detail?

In theory exceptions should be for exceptional cases meaning
no drowning in emails.

On 12/11/2013 6:23 PM, RVic wrote:
> On Wednesday, December 11, 2013 5:55:34 PM UTC-5, RVic wrote:
>> Is anyone aware of a public domain package that can email you on an error, include the stack trace or log, whenever an exception occurs? Thank you, RVic
>
> Looking to send an email on exceptions that are caught, and a general one for those that are uncaught.
>
> I dont mind if there are a ton of emails!

I honestly do not know how many exceptions are thrown each
second in a "typical" Java program. As I said in another post
I think you'd have to modify the JVM to find out -- or maybe
you could use something in java.lang.instrument, a package I've
never had occasion to unwrap. Perhaps you should loosen that
ribbon a bit before writing "I want ALL of them!" on your
Christmas list.

But even if it's only one per second, you'll get 86400 per
day. Can you read 86400 E-mails in one day? Can you find the
four "different" stack traces among those 86400? Remember: You
have ONE second to make up your mind about each of them, if you
don't want to fall behind! Less, if you're monitoring more than
one Java environment ... Try this experiment: Turn off all your
spam filters, and opt out of any that your ISP offers, and tell
us how smoothly you deal with the onslaught.

Another little matter: At a rate of >= 1 E-mail/second, many
mail servers will say "Spammer!" and refuse to cooperate. What
are the chances that any of the "interesting" E-mails will be
among those that get through before the boom is lowered?

If you're in a position to write `catch' blocks to separate
the "possibly interesting" from "certainly boring" exceptions,
java.util.logging.Handler has sufficient hooks to spew info to
an agent that will E-mail it. But ALL exceptions!? I can't think
of any way (even in principle) to do that with a stock JVM, and
I can't imagine that you'd get anything usable out of it.

On 12/11/2013 9:09 PM, Eric Sosman wrote:
> On 12/11/2013 6:23 PM, RVic wrote:
>> On Wednesday, December 11, 2013 5:55:34 PM UTC-5, RVic wrote:
>>> Is anyone aware of a public domain package that can email you on an
>>> error, include the stack trace or log, whenever an exception occurs?
>>> Thank you, RVic
>>
>> Looking to send an email on exceptions that are caught, and a general
>> one for those that are uncaught.
>>
>> I dont mind if there are a ton of emails!
>
> I honestly do not know how many exceptions are thrown each
> second in a "typical" Java program. [...]

.... but I found a twelve-year-old paper about optimizing both
the exceptional and unexceptional execution paths ("A Study of
Exception Handling and Its Dynamic Optimization in Java," by
Ogasawara, Komatsu, and Nakatani). It contains a table counting
how many exceptions are thrown by various programs. Some excerpts:

On 12/11/2013 08:08 PM, Arne Vajhøj wrote:
> On 12/11/2013 6:13 PM, Eric Sosman wrote:
>> On 12/11/2013 5:55 PM, RVic wrote:
>>> Is anyone aware of a public domain package that can email you on an
>>> error, include the stack trace or log, whenever an exception occurs?
>>
>> I think you'd have to modify the JVM itself to do this. But
>> you wouldn't want to: If you got an E-mail for every exception
>> thrown, you'd drown in E-mail.
>>
>> Presumably, what you really want is E-mail about "important"
>> exceptions, and the hard part is clarifying what "important" means.
>> Could you describe your use case in more detail?
>
> In theory exceptions should be for exceptional cases meaning
> no drowning in emails.
>
> I have seen many apps where your concerns are valid though.
>
> Arne
>
It's true that exceptions are for exceptional cases. The Java tutorial
says that:

"An exception is an event, which occurs during the execution of a
program, that disrupts the normal flow of the program's instructions."

However, as you yourself admit, Arne, there are many apps where there
are frequent exceptions. And no small number of these apps are actually
well-designed.

As an example (and this is based on a setup I am familiar with),
consider an ESB app that mediates between 2 systems: A and B. System A
is a source of data for system B, but both are unaware of each other,
and the data must be transformed before it goes into B. The hitch is,
the ESB app has no ability to do more than very simple validation, and
System A has a fair bit of bad data, because of human data entry and
configuration reasons [1]. Hence, System B must validate (because it
knows what it can accept), and this works OK.

The validation errors must come back to the ESB app, since the ESB app
is the controlling intelligence. They come back as SOAP faults (Java
runtime exceptions), which is appropriate.

Furthermore, the ESB app polls System A, and communicates with System B
using SOAP, every few minutes (this interval being configurable but
dictated by business requirements).

So the first few months we were getting a few dozen SOAP faults every
few minutes, so say about 500-1000 every hour, or 10-20 thousand a day.

Thing is, 99 percent of those 10-20 thousand SOAP faults were for the
same few dozen bad data entries in System A. Sending an email for each
of those would have overwhelmed the human recipients. We recognized that
a separate ESB job that ran every 24 hours (and effectively called the
same intermediary logic) would capture all the problems, and it could
send out a *single* email that provided a summary of the bad data in
system A (and why it was bad).

Point being, email notification on errors (as with logging errors to
file etc) are almost always going to a human being [2]. As such, the
urgency of an error dictates whether a notification should be sent at
all, how often an email should be sent, who gets it (human or system),
the nature of the email content (summary or single event), etc etc.

To wit, for a large percentage of apps I think an "email per exception"
strategy will lead to drowning in emails. And you can Splunk or
grep|uniq|cut|cat|paste all that to your hearts's content...essentially
wasting your time to do what the reporting systems could have done in
the first place.

AHS

1. The fixes for which, in a unionized and bureaucratic environment, are
not simple.

2. I suppose you could send a stringified object reference to a CORBA
client...
--
When a true genius appears, you can know him by this sign:
that all the dunces are in a confederacy against him.
-- Jonathan Swift

On 12/13/2013 11:44 AM, Arved Sandstrom wrote:
> On 12/11/2013 08:08 PM, Arne Vajhøj wrote:
>> On 12/11/2013 6:13 PM, Eric Sosman wrote:
>>> On 12/11/2013 5:55 PM, RVic wrote:
>>>> Is anyone aware of a public domain package that can email you on an
>>>> error, include the stack trace or log, whenever an exception occurs?
>>>
>>> I think you'd have to modify the JVM itself to do this. But
>>> you wouldn't want to: If you got an E-mail for every exception
>>> thrown, you'd drown in E-mail.
>>>
>>> Presumably, what you really want is E-mail about "important"
>>> exceptions, and the hard part is clarifying what "important" means.
>>> Could you describe your use case in more detail?
>>
>> In theory exceptions should be for exceptional cases meaning
>> no drowning in emails.
>>
>> I have seen many apps where your concerns are valid though.
>>
>> Arne
>>
> It's true that exceptions are for exceptional cases. The Java tutorial
> says that:
>
> "An exception is an event, which occurs during the execution of a
> program, that disrupts the normal flow of the program's instructions."
>
> However, as you yourself admit, Arne, there are many apps where there
> are frequent exceptions. And no small number of these apps are actually
> well-designed.
>
> As an example (and this is based on a setup I am familiar with),
> consider an ESB app that mediates between 2 systems: A and B. System A
> is a source of data for system B, but both are unaware of each other,
> and the data must be transformed before it goes into B. The hitch is,
> the ESB app has no ability to do more than very simple validation, and
> System A has a fair bit of bad data, because of human data entry and
> configuration reasons [1]. Hence, System B must validate (because it
> knows what it can accept), and this works OK.
>
> The validation errors must come back to the ESB app, since the ESB app
> is the controlling intelligence. They come back as SOAP faults (Java
> runtime exceptions), which is appropriate.
>
> Furthermore, the ESB app polls System A, and communicates with System B
> using SOAP, every few minutes (this interval being configurable but
> dictated by business requirements).
>
> So the first few months we were getting a few dozen SOAP faults every
> few minutes, so say about 500-1000 every hour, or 10-20 thousand a day.
>
> Thing is, 99 percent of those 10-20 thousand SOAP faults were for the
> same few dozen bad data entries in System A. Sending an email for each
> of those would have overwhelmed the human recipients. We recognized that
> a separate ESB job that ran every 24 hours (and effectively called the
> same intermediary logic) would capture all the problems, and it could
> send out a *single* email that provided a summary of the bad data in
> system A (and why it was bad).
>
> Point being, email notification on errors (as with logging errors to
> file etc) are almost always going to a human being [2]. As such, the
> urgency of an error dictates whether a notification should be sent at
> all, how often an email should be sent, who gets it (human or system),
> the nature of the email content (summary or single event), etc etc.
>
> To wit, for a large percentage of apps I think an "email per exception"
> strategy will lead to drowning in emails. And you can Splunk or
> grep|uniq|cut|cat|paste all that to your hearts's content...essentially
> wasting your time to do what the reporting systems could have done in
> the first place.

Well - I am not convinced that the exception is the right choice
when the data quality is as it is resulting in 10-20 thousand
exceptions per day.

But that type of scenario is seen frequently.

But given the question, then I am not expecting the original
poster to be working on that type of application.

On 12/14/2013 05:36 PM, Arne Vajhøj wrote:
> On 12/13/2013 11:44 AM, Arved Sandstrom wrote:
>> On 12/11/2013 08:08 PM, Arne Vajhøj wrote:
>>> On 12/11/2013 6:13 PM, Eric Sosman wrote:
>>>> On 12/11/2013 5:55 PM, RVic wrote:
>>>>> Is anyone aware of a public domain package that can email you on an
>>>>> error, include the stack trace or log, whenever an exception occurs?
>>>>
>>>> I think you'd have to modify the JVM itself to do this. But
>>>> you wouldn't want to: If you got an E-mail for every exception
>>>> thrown, you'd drown in E-mail.
>>>>
>>>> Presumably, what you really want is E-mail about "important"
>>>> exceptions, and the hard part is clarifying what "important" means.
>>>> Could you describe your use case in more detail?
>>>
>>> In theory exceptions should be for exceptional cases meaning
>>> no drowning in emails.
>>>
>>> I have seen many apps where your concerns are valid though.
>>>
>>> Arne
>>>
>> It's true that exceptions are for exceptional cases. The Java tutorial
>> says that:
>>
>> "An exception is an event, which occurs during the execution of a
>> program, that disrupts the normal flow of the program's instructions."
>>
>> However, as you yourself admit, Arne, there are many apps where there
>> are frequent exceptions. And no small number of these apps are actually
>> well-designed.
>>
>> As an example (and this is based on a setup I am familiar with),
>> consider an ESB app that mediates between 2 systems: A and B. System A
>> is a source of data for system B, but both are unaware of each other,
>> and the data must be transformed before it goes into B. The hitch is,
>> the ESB app has no ability to do more than very simple validation, and
>> System A has a fair bit of bad data, because of human data entry and
>> configuration reasons [1]. Hence, System B must validate (because it
>> knows what it can accept), and this works OK.
>>
>> The validation errors must come back to the ESB app, since the ESB app
>> is the controlling intelligence. They come back as SOAP faults (Java
>> runtime exceptions), which is appropriate.
>>
>> Furthermore, the ESB app polls System A, and communicates with System B
>> using SOAP, every few minutes (this interval being configurable but
>> dictated by business requirements).
>>
>> So the first few months we were getting a few dozen SOAP faults every
>> few minutes, so say about 500-1000 every hour, or 10-20 thousand a day.
>>
>> Thing is, 99 percent of those 10-20 thousand SOAP faults were for the
>> same few dozen bad data entries in System A. Sending an email for each
>> of those would have overwhelmed the human recipients. We recognized that
>> a separate ESB job that ran every 24 hours (and effectively called the
>> same intermediary logic) would capture all the problems, and it could
>> send out a *single* email that provided a summary of the bad data in
>> system A (and why it was bad).
>>
>> Point being, email notification on errors (as with logging errors to
>> file etc) are almost always going to a human being [2]. As such, the
>> urgency of an error dictates whether a notification should be sent at
>> all, how often an email should be sent, who gets it (human or system),
>> the nature of the email content (summary or single event), etc etc.
>>
>> To wit, for a large percentage of apps I think an "email per exception"
>> strategy will lead to drowning in emails. And you can Splunk or
>> grep|uniq|cut|cat|paste all that to your hearts's content...essentially
>> wasting your time to do what the reporting systems could have done in
>> the first place.
>
> Well - I am not convinced that the exception is the right choice
> when the data quality is as it is resulting in 10-20 thousand
> exceptions per day.

It is however the right choice for SOAP. Altering the body to introduce
error result codes introduces extra coupling between systems; SOAP
faults (which translate into Java runtime exceptions) are the standard
way of handling data validation errors, among other things.

That one system has poor data doesn't change this.
> But that type of scenario is seen frequently.

You betcha.
> But given the question, then I am not expecting the original
> poster to be working on that type of application.
>
> Arne

I'm not convinced that he is or isn't, Arne. The OP seemed to be
ostensibly OK with handling high volumes of emails...although that may
be seriously optimistic on his part.

AHS
--
When a true genius appears, you can know him by this sign:
that all the dunces are in a confederacy against him.
-- Jonathan Swift

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!