Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to have WordPress email the site administrator whenever a PHP error message is displayed? Ideally the message would also be filtered out of the HTML output, so as to avoid information disclosure.

I ask because, while @ini_set('display_errors', 0); is at the top of my wp-config.php and working nicely, I want to receive notifications about errors.

I will happily write a custom plugin to do this, if someone who knows more about WP can point me in the direction of where I might hook in to get the job done.

Final bit: Am I crazy for wanting something this out-of-the-ordinary?

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

Displaying PHP errors isn't really a WordPress thing, it is more of a PHP thing directly. No, I don't think you are crazy for wanting this, I had a similar need for a separate application and I wrote this blog post which should be helpful.

Essentially, define your own error handler.

share|improve this answer
    
It looks like that would email me about every little mistake in every plugin I use. I tried a custom error handler in wp-config and it printed screens-full of minor notices. However, what I really want is a different question, so I'll pick an answer here and ask a new question. –  dgw Jun 21 '11 at 22:47
add comment

Typically, as v0idless mentioned, this is done on the server side, There any many tools to manage error logs and emails out there. The error log reporting on the server end is much more detailed than you could write in a plugin.

Though I have never tested it I believe error_log php function supports email. http://php.net/manual/en/function.error-log.php

Reporting constant errors can kill your site/server depending on the error threshold you have set, I recommend you just email the error.log file once every few hours/days.

For instance on the server end:

  • All fatal or hard errors are in a separate log file which is emailed immediately.( Also instant message/cell phone support).

  • All other errors in are in another log file emailed every 24 hours ( which I never read:) )

  • They log files are also backed up every day.

I actually use rubygems to do this stuff since it's so damn easy.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.