How to Find and Clean Up WordPress Errors
An ounce of prevention is worth a pound of cure – Benjamin Franklin
Each summer I like to spend time looking at the error logs of the sites I manage in order to see what might be causing unknown issues. By addressing any errors that show in the error logs, you can easily keep code clean, up-to-date, and ready for any upgrades.
By adding this to the wp-config.php error log will create a log file in /wp-content/ called debug.log for your review:
define( 'WP_DEBUG', true ); // Or false
if ( WP_DEBUG ) {
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', false );
}
Note – if your site gets a lot of traffic – that log file can grow quite quickly. After you turn in logging with the change to wp-config.php – check back in an hour and see if you have sufficient data to work with. Turn off the debugging, make the changes, rinse/repeat. If you have lower traffic – you can keep it on longer, but set a reminder to look after a day at the most so the file does not get too big.
After the debug.log file is populated – you will then be able to see PHP warnings, depreciated notices, as well as fatal errors. I would recommend addressing any fatal errors first, then moving to the warnings and other notices in your custom code. Make sure all your plugins and WordPress files are up to date but also note that you might see some errors related to either of those. You can choose to contact the plugin developers, or work with the WordPress developers to fix any issues with WordPress core, but any other errors you see with any custom code on the site will allow you to fix/update your custom code in order to make the site(s) run quicker and bug free.
It is always good to check the error logs periodically in order to make sure all is running as smooth as possible. This will also make troubleshooting a serious problem easier in the future by making sure your error log is not full of notices, minor issues which can make finding the real issue harder to debug.