justinl
justinl

Reputation: 10548

Best Practices for Live Website Error Management

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

Upvotes: 6

Views: 1565

Answers (5)

joebert
joebert

Reputation: 2663

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.

Upvotes: 0

MaxiWheat
MaxiWheat

Reputation: 6251

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.

Upvotes: 5

scunliffe
scunliffe

Reputation: 63588

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.

Upvotes: 0

Justin Johnson
Justin Johnson

Reputation: 31300

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.

Upvotes: 2

Valentin Golev
Valentin Golev

Reputation: 10095

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

Upvotes: 0

Related Questions