tags:

views:

133

answers:

5

I am just about to launch a fairly large website for the first time. I have turned off all error messages in my php.ini and error messages are now logged to an "error_log" file on my server.

My question is, now that the errors are logged to a file, what are the best ways that web developers keep on top of seeing when/where errors occur on the website?

At the moment, it seems like the best way would be to constantly check the error_log file everyday, however this doesn't seem like the most efficient solution. Ideally I would receive an email everytime an error occurs (with the error message). Any advice on how I can keep on top of errors would be greatly appreciated!

Extra Info
Running on Shared Server (HostMonster)
Website Authored in PHP

A: 

You can email yourself on errors, if there was no email in last N hours.

valya
+1  A: 

The place I previously worked at used a custom extension to handle error logging. It basically INSERT DELAY the errors into a DB with some extra information. Then, a separate admin tool was written to be able to easily search, browse, sort and manually prune the log table.

I recommend that you don't write a custom extension, but that you use the set_error_handler method and just write to a DB instead. If the DB is unavailable, then write to a file as a backup. It'll be worlds easier than dealing with a huge file and a one-off format.

If you want, you can also email yourself hourly summaries, but I don't suggest you send anything more than that or you'll be hating yourself.

Justin Johnson
one point to note here is that set_error_handler() doesn't handle all error types (from php.net): The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called.
AvatarKava
Wanting error reporting about the broken error reporting mechanism is kind of paradoxical, isn't it?
Justin Johnson
A: 

If you don't expect many errors, a "private" RSS/ATOM feed might work well... whereby you don't need to worry if you don't get anything... but if you start getting "updates" you know there are issues.

scunliffe
+4  A: 

There are two main functions in PHP that help catching errors and exceptions. I suggest that you take a look at them :

In our company, we handle all errors that occurs on our websites with those functions, defining our own errors and exceptions handling methods.

When an error occurs, an email is sent to the developers team.

MaxiWheat
Thanks MaxiWheat. If I'm to go this route, then on every PHP script I'll need to include my custom error handler, right?
justinl
Yes, that custom handler needs to be included in every script. If you don't want bothering, you can use it in an auto prepend file, more info here : http://php.net/manual/en/ini.core.php
MaxiWheat
A: 

I don't know how Hostmonster handles log rotation, but generally you want to monitor the size of your error_log file. If the size jumps suddenly, there's definitely something you need to check up on so you'ld want to get an email telling you that the logfile size jumped unexpectedly.

Other than that, you can combine the error logs at the end of the week and email them to yourself and debug on the weekend. If an error is only happening a few times a week it's probably not too serious of an issue.

joebert