To debug WordPress many sites will tell you to add the WP_DEBUG setting on its own to your wp-config.php file, but this can be quite harmful as many server configurations will start showing PHP errors and warning messages on your site pages. Most sites will also log any errors to some form or error log, but this isn't always the best place for them to go.
It is possible to add a set of debug options that will allow WordPress to log any errors or warnings to a file. Open up your wp-config.php file and add the following lines of code above the line that says "/* That's all, stop editing! Happy blogging. */". Any changes to this file should always go above this line so that you can keep track of them.
What these options do is create a file called debug.log in your wp-content directory. If your folder permissions are quite restrictive then you might want create this file manually and setting the permissions on the file to 666. If WordPress is able to create it then the permissions are probably fine, although you might have trouble doing anything with it over FTP.
The code presented here is ideal because it only creates/updates the log file when you have debug turned on. Whereas the code presented on the codex page keeps writing to the log regardless.
To test this out I added the following line of code (which produces an error) into the TwentyTen theme on a fresh WordPress install and then loaded the site.
Taking a look in the wp-content/debug.log file reveals that the error message that this code produces is now stored in this file.
- [20-Jun-2011 17:06:56] PHP Warning: Constants may only evaluate to scalar values in /var/www/wordpress/wp-content/themes/twentyten/index.php on line 3
Remember to turn debugging off when you have finished your investigation. This can be done by either removing the code entirely or by setting the value of WP_DEBUG to false, preventing the rest of the debugging code from running.
Thanks to Mike Little for letting me know about these options.