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. Read how to enable the WordPress debug log. Debugging and logging WordPress and WooCommerce errors can be very helpful. Four ways to get WordPress and WooCommerce logs. Also, learn some debugging tips for better troubleshooting.
Contents
- Four ways for debugging in WordPress and WooCommerce
- WordPress debug file: how to use it?
- WordPress debug & WooCommerce logs: questions
- What is debugging?
- Debugging in WordPress and WooCommerce: why does it matter?
- What is the WordPress debug log location?
- Can one change the default location of the debug file?
- WordPress debugging is not working: what to check?
- Is it ok for a debug.log to have ~1GB?
- How to set a WordPress debug from false to true?
- How to enable WordPress debug?
- How to turn off debugging in WordPress?
- "There has been a critical error on your website. Learn more about debugging in WordPress." What to do?
- Do you need a plugin to debug in WordPress?
- Are there any tools for debugging?
- What is the impact of debugging on the site's performance?
- What are common error messages in WordPress?
- How to troubleshoot in WordPress and WooCommerce?
- Is debugging email delivery possible?
- How to read the error messages?
- Where to get support in case of WordPress errors?
Four ways for debugging in WordPress and WooCommerce
The methods log the errors to a text file.
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-config.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. It's the default debug log location in WordPress.
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 the 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.
WordPress debug file: how to use it?
You may use the debug.log and WooCommerce logs to diagnose and fix issues. Thus, WordPress logging can help in troubleshooting and when contacting technical support. Debugging is necessary when a site encounters a fatal or critical error.
WordPress debug & WooCommerce logs: questions
What is debugging?
It's the process of finding and fixing the cause of errors, slow code/ site, plugin conflict, site misfunction, or missing scripts.
Debugging in WordPress and WooCommerce: why does it matter?
Using WordPress and WooCommerce logs can help in finding the cause of errors and possible code improvements.
Usually and obviously, you will think about debugging when some errors or notices pop up. In a worse case, you will see a blank page - in that case, WordPress debugging is critical to restore the site.
What is the WordPress debug log location?
The default location is inside the /wp-content/ folder with debug.log as the name.
Can one change the default location of the debug file?
Yes. It's possible by adding a location and a file name to WP_DEBUG_LOG, for example:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', '/logs/errors.log' );
WordPress debugging is not working: what to check?
If the debug log file is not created:
Check the file permission on the /wp-content/.
Also, see if the code e.g.
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
is present and before the /*That's all, stop editing...*/ line in wp-config.php.
It's possible that debug.log gets no new data because WP_DEBUG or WP_DEBUG_LOG are set to false (or the second one is not present).
Is it ok for a debug.log to have ~1GB?
It depends on the error scale. It may happen that the debug file will have MB or GB, but you may delete it after you're done with debugging or fixing the issue. That could be also a smart task to do, for example, because:
- of server/ hosting limits
- users and bots may be able to see errors
- a file may be accessible because of file permission
- new errors in the file will be visible without scrolling
How to set a WordPress debug from false to true?
Edit the wp-config.php file and set the WP_DEBUG, WP_DEBUG_LOG, WP_DEBUG_DISPLAY, or SCRIPT_DEBUG or SAVEQUERIES for saving database queries (be aware of the effect on the site performance after setting it to true).
How to enable WordPress debug?
You can follow the steps below or contact technical support.
- Connect via FTP or the hosting's file manager.
- Download wp-config.php from the main folder of the WordPress installation (where the wp-content folder is).
- Back up the file.
- Edit the file in a text editor.
- Add
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false ); - Decide about displaying logs (with true).
- Save and upload the file overwriting the existing wp-config.php.
- Run the site to trigger the issue again.
- Open the /wp-content/ folder to look for the debug.log file.
- Download the file for troubleshooting.
How to turn off debugging in WordPress?
You may disable the WordPress log after testing or troubleshooting. Especially, remember about changing WP_DEBUG_DISPLAY to false. Otherwise, users may still see error messages and notices on the frontend.
To turn off debug mode entirely, open the wp-config.php file (via FTP or file manager) and set WP_DEBUG to false.
You may also upload the previous version of wp-config.php (without WP_DEBUG).
"There has been a critical error on your website. Learn more about debugging in WordPress." What to do?
You may see the message and get an email if WordPress encounters the error. In that case, you may contact technical support, a developer, plugin authors, hosting provider, or start troubleshooting yourself.
Do you need a plugin to debug in WordPress?
Not necessarily. If you see one or a few errors inside the logs, you probably don't need extra plugins.
You or technical support may use the log entries to diagnose the issue and help fix it. It may also happen that the issue is related to some scripts. In that case, it's possible to use the browser console (Ctrl+Shift+I) to find JavaScript errors and messages or a plugin.
Saving queries (with SAVEQUERIES set to true) takes space and slows down the WordPress database. You may check out the official WordPress documentation about saving queries and script logging.
Are there any tools for debugging?
You may use a text editor to read the error messages and notices. It's also possible to see the logs in WooCommerce → Status → Logs. Depending on the number of errors you may just copy them to use for troubleshooting. If there are repetitions, take a look if the cause is always the same or different as it could suggest that the issue is complex.
What is the impact of debugging on the site's performance?
Additional tools will use extra memory. If you save queries or use an additional plugin the site performance may also be affected. You may disable and delete the DEBUG lines in wp_config.php and tools after troubleshooting.
Moreover, if you disable a plugin or change a theme, the site can be down or miss some functionalities. You may consider informing users about possible temporary effects or testing on a development environment first.
What are common error messages in WordPress?
Let's take a look at some examples of notices/ code you may encounter when debugging.
Error message examples
- Fatal error: Allowed memory size of 12345678 bytes exhausted (tried to allocate 2345678 bytes) in /home/your-username/public_html/wp-includes/plugin.php on line 1000
- Fatal error: Out of memory (allocated 12345678) (tried to allocate 2345678bytes) in /home/your-username/public_html/wp-includes/plugin.php on line 1000
- There has been a critical error on this website.
- Function create_function() is deprecated.
- PHP fatal error: cannot redeclare function previously declared.
- PHP fatal error: call to undefined function.
- Fatal error: maximum execution time of 30 seconds exceeded in
- Fatal error: uncaught error.
How to troubleshoot in WordPress and WooCommerce?
First, remember about the site's backup so that you may restore the page.
If you don't have a staging area to test the issue or error's cause and you use a live site:
- Back up the site including the WordPress database.
- Consult the issue with the support (plugin's authors, web developer, hosting provider, or theme's support forum).
- Read the error messages.
- If the issue is related to PHP, file permission, server settings, or memory limit, contact the hosting provider.
- If the issue is software-related, you may turn off plugins (all or one by one) or change a theme.
- If no wp-admin is accessible, you may connect to FTP/ file manager and change the name of a theme/ plugin's folder e.g. by adding -test to the folder's name. Of course, if the issue was caused by one of them and you feel confident about changing it yourself on a live site.
Is debugging email delivery possible?
Yes. You may use a plugin to track and log email delivery from WordPress or WooCommerce. Sometimes, not sending emails may be related to SMTP settings, server restrictions, cron misfunction, plugin issues, or emails landing in spam.
How to read the error messages?
- Download the WordPress log file or logs from WooCommerce → Status → Logs.
- Open files in a text editor.
- Find the error message close to the time you've noticed/ encountered the issue.
- Use the information to fix the issue or consult the issue with support team (below).
Where to get support in case of WordPress errors?
You may contact the company/ person that built the website. If the issue is related to a theme or plugin, contact the software developers. If the issue is WordPress or WooCommerce related you may report it:
For other/ plugin compatibility issues you may also hire someone/ company to run the diagnostics and help.
WP Desk Care & Plugins
If you need technical support with errors you may check out the service.
💡 You may also see WP Desk plugins for WordPress & WooCommerce