How to setup a PHP Error log for WordPress – Revisited
There are a few hosts that do not give you an easy ability to see php errors that might happen. The first step is to edit your wp-config.php in your installation root directory.
Add these lines:
ini_set( 'display_errors', 0 ); ini_set( 'log_errors', 1 ); ini_set( 'error_log’, WP_CONTENT_DIR . '/debug.log' );
Although the use of WP_CONTENT_DIR doesn’t work for me, I did this instead.
ini_set( 'error_log', dirname(__FILE__) . '/wp-content/debug.log' );
Also, since I don’t want all those silly notices and warning clogging up my debug.log file, I just want errors only, I do this:
ini_set( 'error_reporting', E_ALL ^ E_NOTICE );
This line basically tells the php parser to report all errors, except notices. If more plugin programmers would test their plugins with the notices on then I wouldnt have 3 pages of notices come up inside the debug.log file.
So in summary:
ini_set( 'display_errors', 0 ); ini_set( 'log_errors', 1 ); ini_set( 'error_log', dirname(__FILE__) . '/wp-content/debug.log' ); ini_set( 'error_reporting', E_ALL ^ E_NOTICE );
Based on the comments section, this is a more proper route to go then actually using the defines that were written into the code, dunno why but I take people who know the wordpress core code better then me at their word. Thanks guys for great comments.
Then if you navigate to your server’s wp-content directory there will be a debug.log waiting for you with information in it about what is wrong with your wordpress if an error ever happens.
PHP.Net Manual on ini_set: http://www.php.net/ini_set
– Phil (Frumph)