When you are working with PHP scripts, errors may occur. It may happen that the PHP interpreter won't display the error in the browser. Displaying errors can be helpful in locating the source of issues that you are experiencing. Debugging and logging errors to a text file can be very helpful.
Here are four ways to turn the debugging on in WordPress and WooCommerce and log the errors to a text file:
WooCommerce logs
WooCommerce has a built-in functionality of automated error logging. Logs can be accessed through: WooCommerce -> Status -> Logs.
Select a file from a dropdown list. The one with the error log starts with fatal-errors. Please keep in mind that these logs are automatically erased after 30 days.
Editing wp-config.php file
Sometimes the error occurs on a different layer, before the WP Desk Helper functions even start. This means that error won't be saved by WP Desk Helper and you need to start built-in WordPress debugging process. It is not available through the admin panel. In order to switch it on, you need to manually edit the wp-config.php file. Open /wp-content.php file and add following lines (at the end of a file):
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
Error log will be saved to /wp-content/debug.log.
PHP error logging - editing php.ini
PHP interpreter can as well log your errors. Using this solution, you can be sure that all errors and warnings will be saved, regardless which layer they occur on. To switch on global error logging, edit the php.ini file.
Open the php.ini files and following lines:
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
The file will be saved in this location: /tmp/php-error.log.
Visit web hosting control panel or contact your server administrator
It may happen that error logging won't work at all on your server and the solutions listed above will fail. In that case, you need contact your server administrator and ask him to share error log file with you. Many of the web hosts saves such logs by default. In the most of the web hosting control panels, there is a way to download the error log file without need of contacting web host support.
WP Desk Plugins
💡 If you came across this article by chance and want to see what plugins we have to offer, we recommend you visit our portfolio:
WP Desk Plugins →