Troubleshooting WordPress can sometimes be tricky. You might have gone through the usual steps to fix the most common WordPress errors like disabling the plugins, switching to the default theme, deleting the .htaccess file, etc. But the nagging error refuses to go.
In this scenario, you should turn on error logging in WordPress. The error log file, as the name indicates, logs or records the PHP and other errors as they occur on your website.
You can then identify the source of your troubles by going through the error log. In this post, I will explain how to set up and locate the WordPress error log in 2 easy steps.
Let’s get started.
Step 1: Setting up the WordPress error log
Before you can locate the error log, you first need to turn on WordPress debugging by navigating to the wp-config.php file in your root WordPress directory.
If you scroll down, you will see the following snippet:
Now change false to true and save the file.
It could also be that the snippet is not present in your wp-config.php file. In this case, you should copy and paste the following snippet just before the line that reads: “That’s all, stop editing! Happy blogging.”
This will turn on debugging on your website the errors will be displayed on the screen, both on the backend and the front-end.
But this is not ideal since we don’t want our website visitors to see the errors.
For this reason, you should turn off the debug display by adding the following line of code just after the earlier line:
Finally, we need to create an error log file to record the errors as they occur on your website by adding this third line:
This command tells WordPress to create an error log.
Step 2: Locating the WordPress error log
Now that you have turned on debugging and created the error log, it’s time to access this file. The error log is stored in a file named debug.log.
The debug.log file is located in the wp-content folder. So, you just need to navigate to this folder to access the error log by opening the debug.log file.
The debug.log file contains a list of errors taking place on your website. You should go through this file to locate the source of the error that you’re looking to troubleshoot.
There are a host of WordPress bugs that the error log will help to troubleshoot like:
- 500 Internal server error
- Site can’t be reached error
- WordPress critical error
- Memory exhausted fatal error
Remember that the debug.log file is publicly accessible and you should turn off debugging after you’ve completed the troubleshooting by changing the define(‘WP_DEBUG’, true); snippet to define(‘WP_DEBUG’, false);
Finally, you should know that the error log contains mostly PHP errors occurring on your site that you may find hard to troubleshoot on your own.
Fortunately, help is at hand in the form of our affordable WordPress debugging service that is quick and reliable.
If you need more help in locating the WordPress error log, leave a comment and I will be happy to help you further.