Debugging is a method that has been used traditionally to fix hard to detect issues in software. WordPress websites usually run smoothly but there might be instances where it becomes necessary to monitor the performance and activity of various plugins and themes. In cases where there might be a possible memory leak or you might want to identify the manner in which scripts interact with each other, it is necessary to debug your WordPress installation and determine if an improvement can be made.
Debugging on a WordPress website is quite easy. There are flags in the wp-config.php file that will allow you to enable debugging. These flags are turned off by default which means that no errors are sent to the browser. This is the reason behind the notorious white screen of death that almost every WordPress user has encountered at one point or another. When you turn on the WP_DEBUG flag, you will have the errors messages displayed on the site, letting you know which plugins are causing problems. This might be the quickest way to find the issues plaguing your site but it is not the most user friendly. Who would want all their users to see errors on every page. It is therefore important to save all your debug logs in a separate file. What you need to do is open the wp-config.php file and add these lines:
1 2 3 4 5 6 7 8 9 10 | // Enable WP_DEBUG mode define ('WP_DEBUG', true); // Enable Debug log to the /wp-content/debug.log file define ('WP_DEBUG_LOG', true); // Disable display of errors and warnings define ('WP_DEBUG_DISPLAY', false); @ini_set('display_errors',0); |
The above code will help you find out the problems in your PHP. However if you suspect that the problem lies in the JavaScript then you will have to add this as well:
1 2 | // Use dev versions of core JS and CSS files define ('SCRIPT_DEBUG', true); |
Once you are done, save the file and close. This will tell WP not to display the errors in the main browser but rather save them as a separate file. Once you are done, you may check your logs which will be saved in a file at /wp-content/debug.log. If you are unable to make sense of the information in the log files, you can show them to someone more experienced. They would be in a much better position to help you.
Proper debugging is extremely helpful for finding the source of different problems. Unfortunately most people are unaware of this technique so they have to fix problems by deactivating all the plugins and turning them on one by one to find the culprit. This approach is painfully time-consuming and is not always possible.
Leave a reply