Table of contents
Get the industry’s fastest hosting for WordPress ◦ 99.999% uptime
◦ Comprehensive security
◦ 24/7 support

WordPress GuideErrors → Error Logs

Using WordPress error logs to understand activity on your site

wordpress error logs

WordPress has a fairly simple interface, but there is a lot happening beneath the surface that you don’t see. Every page load and configuration change may trigger dozens of functions which, in turn, may trigger dozens more. Most of the time, the activity is hidden and that’s a good thing: you don’t need to know everything your WordPress site does behind the scenes.

But sometimes it’s useful to move the curtain aside and see what’s really happening. WordPress can communicate with you in various ways: it can send you emails, it can display notifications, but today we’re going to look at logs.

A log is a list of events, usually displayed in the order in which they occurred. Logs often include errors, but they might also include the day-to-day activities of your site.

Logs are useful for figuring out what is happening when it isn’t obvious from the interface. For example, you might install and configure a plugin so that a widget is displayed on the home page. If the widget doesn’t appear, you can look at log files for clues about what went wrong. Error logs are also valuable for security monitoring, as they can help identify potential SQL injection attacks and other suspicious activity before they compromise your site.

Manually generate a WordPress error log

WordPress doesn’t produce a log of errors unless you ask it to. There are a couple of ways to get WordPress to generate an error log. We’ll look at doing it manually first.

In the root of your WordPress installation is a file called wp-config.php. It includes variable definitions and other code for configuring WordPress. You can edit this file by SSHing into your WordPress hosting account or by using an FTP client like Filezilla.

To turn on the error log, look for code that says:

define( 'WP_DEBUG', false );

Change it to the following:

define( 'WP_DEBUG', true );

This turns on debugging, but you also need to add another line so that WordPress sends errors to a log:

define('WP_DEBUG_LOG', true);

Make sure that there is only one occurrence of the WP_DEBUG and WP_DEBUG_LOG definitions in wp-config.php.

Now, if you look in your WordPress installation’s /wp-content directory, you will find a file called debug.log that contains errors and other useful information. As you carry out actions on your site, any errors, such as ‘Not a valid JSON response‘, generated by the site’s code are added to the log.

When you have finished using the log, it’s a good idea to turn off log generation by returning wp-config.php to its default state.

Error log plugins: An easier method

If editing the wp-config.php file manually and viewing logs over Filezilla doesn’t sound like fun, you can use a plugin to toggle logging and view the log. There are a few options in the WordPress plugin library, including:

There are even some free options:

Additional resources

Diagnosing WordPress errors on your site →

Even more common errors, how to troubleshoot them, and how to solve them

Comprehensive WordPress security checklist →

18 tasks anyone can implement to make your WordPress site more secure

What is managed WordPress hosting? →

What it means, what it includes, and how to decide if it’s right for you