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.

I'm trying to find a solution on how to handle the displaying and logging of errors in a PHP (Wordpress) production environment.

Is it possible to do the following (alternative suggestions welcome):

  • Capture critical errors and send immediate email notification (this looks like a promising solution, but haven't tested in my production env yet).
  • Don't display PHP errors on screen to visitors. Instead display a custom built error page. Something that's friendlier than the PHP "white screen of death". This includes the Wordpress specific errors, like the "Error establishing a database connection" one.

Production environment details specific to this question:

  • WordPress 3.5.1
  • Web Host: Windows Azure Cloud
  • Web Server: IIS 7.5

What I've already configured:

  • Development (local), Staging and Production enviroments
  • Code is managed in source control (Team Foundation Server Version Control)
  • Tested builds are pushed to production (Windows Azure Cloud)
  • I have configured wp-config for multiple environments:

    • Development and Production connect to different databases.
    • Development configs:

      • WP_DEBUG = true
      • WP_DEBUG_DISPLAY = true
      • WP_DEBUG_LOG = true
      • display_errors (via @ini_set) = true
    • Production configs:

      • WP_DEBUG = false
      • WP_DEBUG_DISPLAY = false
      • WP_DEBUG_LOG = true
      • display_errors (via @ini_set) = false
share|improve this question

1 Answer 1

It's best to just log errors to the server and then use bash or a server script that supports email and error analysis (instead of PHP). There are lots of log file tools out there, simple ones like Logwatch, Swatch, Octopussy, or more complex ones like Nagios.

For errors which are triggered using WP_Error you can write an email alert or log function right into the class, that is if it's your code.

I recommend checking this out: https://github.com/pippinsplugins/WP-Logging

Additionally WP supports a maintenance.php and a db-error.php file that you can customize, the last one being more beneficial to your question since it will handle WP related DB errors.

You can of course use PHP to mail errors for example using the above: http://yoast.com/custom-wordpress-database-error-pages/

But your really better off using log files and a log analyzer to do this type of work on a production server.

share|improve this answer
    
thanks for your very informative answer. i will explore the use of log files tomorrow, depending on how much access I can get to the server. –  IntricatePixels Apr 12 '13 at 4:11

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.