If you are trying to understand how the WordPress error logs works, you are in the right place! In this guide, we will cover all what you should know about it.
Monitoring PHP errors is something you need to do if you want to keep your WordPress website secure, healthy, and fast. If not fixed, PHP errors can indeed reduce your website performance and increase your website vulnerability to downtime and hackers.
That’s why, in this article, I’ll explain to you what you need to know about the PHP error logs in WordPress: from how to enable WordPress Error Log to implementing a reliable PHP monitoring solution.
Let’s get started with two definitions! If you are in a hurry, you can directly go to the PHP monitoring plugins section.
Table of contents
PHP is the coding language WordPress is built on. When a user requests a web page that contains PHP code, the code is processed by the PHP module (Apache or Nginx) installed on the server.
Processing a request can generate PHP errors. This means that something is wrong with the PHP code. The error can be as simple as a missing semicolon, or as complex as calling an incorrect variable.
PHP errors can be triggered by theme, plugins, database, or server configuration. That’s one of the reasons why you should not install too many plugins on your WordPress websites.
Note that, the most PHP errors that you can see on your WordPress site are usually warnings and notices. This being said, some of them (fatal errors, internal server error, etc) can stop your website from loading.
Here are some of the PHP errors you can encounter.
Indeed, even if your website seems to be working well, it may in fact be suffering from undetected PHP errors that should be fixed ASAP. The WordPress error log gives you the list of these errors.
Error logs provide you with information such as the error type, the error line, and the file concerned. You should use WordPress error logs to troubleshoot arising issues or understand why they’ve happened.
If my explanation still looks blurry and if you don’t see the point of enabling the debugging mode for WordPress, here are some situations where you might really need it:
There are two ways to access PHP error logs in WordPress: manually or with a monitoring plugin. I’d personally advise to use WP Umbrella to monitor your PHP errors. It’s clearly the easiest way.
WP Umbrella is a all-in-one solution to manage WordPress sites. It embed a PHP errors monitoring feature for WordPress.
WP Umbrella is interesting because it also checks your website’s uptime rate and provide you with automatic backups.
You need to install the plugin, create an account and connect your API key.
Then, go to WP Umbrella’s application >> PHP issues.
From here, click on the “view error” to get all the information related to the PHP errors such as:
That’s it, easy peasy!
If you don’t want to use an error log plugin like WP Umbrella or Query monitor, you can enable WordPress error log and retrieve PHP errors from here.
The wp-config.php file contains important WordPress settings like how to connect to your database. This is the file you need to edit in order to enable WordPress debugging mode and access WordPress error logs where you will find your PHP errors.
First, you need to connect to your website using an FTP client. Then, download the
wp-config.php file to make a backup of it. Then you can start editing it with your favorite HTML editor.
Just before the line “That’s all, stop editing! Happy blogging” add this:define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_LOG’, true );
Or write true instead of false if the WP_debug function is already defined.
WP_DEBUG will allow you to enable debug mode and WP_DEBUG_LOG will allow you to send all errors to a file, so PHP errors are not displayed on your pages.
Save your changes and upload the file back to your website. The errors will then get logged to the
debug.file within your
wp-content folder. If you don’t see the file, you can create one.
This is where your WordPress error logs will be stored.
Regrettably, there’s no magic and universal approach to fixing issues that you discovered in your WordPress website’s error log. Every PHP error will need to be troubleshot on its own.
If the PHP error is created by a third-party plugin you need to contact the plugin editor support so it can be fixed permanently. If you try to fix it yourself, the error might just happen again the next time the plugin is updated.
If you are looking for further information, you should check the official documentation of PHP.
If you like this article, you might be interested in our section “troubleshoot WordPress errors“.
A step-by-step guide to troubleshoot WordPress syntax errors.
In this article, I’ll show you how to easily turn off PHP errors in WordPress.
Everything you need to know about the PHP memory limit in WordPress and how to easily increase it to fix the allow memory size exhausted error.