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 locate the source of issues that you are experiencing. Debugging and logging WordPress and WooCommerce errors to a text file can be very helpful. Four ways to get WordPress and WooCommerce logs.
Here are four ways to turn the debugging on in WordPress and WooCommerce and log the errors to a text file:
Contents
1. 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.
2. Editing wp-config.php file to get debug.log
Sometimes the error occurs on a different layer, before the WP Desk Helper functions even start. This means that the error won't be saved by WP Desk Helper and you need to start the 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 the following lines (at the end of a file):
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
The error log will be saved to /wp-content/debug.log.
3. PHP error logging - editing php.ini
PHP interpreter can also log the errors encountered in WordPress and WooCommerce. Using this solution, you can be sure that all errors and warnings will be saved, regardless of layer they occur on. To switch on global error logging, edit the php.ini file.
Open the php.ini files and the 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.
4. Visit the 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 to contact your server administrator and ask him to share the error log file with you. Many of the web hosts save such logs by default. In most of the web hosting control panels, there is a way to download the error log file without the need to contact 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 →
You may also check out the WP Care service.