views:

60

answers:

3

I'm thinking through all the points in my PHP application where it performs some sort of system process like database queries, or sending out an email, and I'm wondering if at all these points I should be notifying a user when something goes wrong. There are so many points where an application can fall apart, that I'm having trouble determining if it is worth it to notify the user. Is it better to have some sort of logging in place, where every few days I just monitor the logs? Is there a standard approach for large-scale applications?

A: 

You could probably use something like log4php, which is a php-based implementation of the famous log4j library. You would then log messages whereever applicable using a 'severity'. Based on two factors - severity and category you configure 'where' and 'how' to log/process/display the messages thanks to the flexible appender system.

While i'm not sure if there is already a complete solution for php, you could for instance have non-severe errors logged to a database and diplayed by admininstration component within your application, while severe errors get sent to you by e-mail and im.

Jan Jungnickel
A: 

From a user perspective everything unexpected (that includes error messages prompts like "Are you sure" or similar) triggers the urge to get rid of it as soon as possible. Users don't read messages and likely won't notify you of problems, so overwhelming a user with technical details is in almost all cases the wrong way to go and you're usually better off with logging or perhaps an e-mail to you when something goes wrong.

As for the user, try to divide yuor failure cases into failures that can be mitigated by retrying and retry automatically before telling the user (but not endlessly) and failures that need administrative action or simply time to solve in which case a generic error message along with a more detailed log message for the developers should be best.

That is, if you're not assuming all your users are developers.

Joey
A: 

Ideally your users will tell you what they want to be notified about as part of your requirements process.

Failing that, you could adopt a guideline like only notifying on situations which require some action on the user's part.

MandyK