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.
Low activity may be due to slow site speed. Here are some simple optimizations to speed up your website.
The 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:
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 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.
An easier option
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. WP Log Viewer allows you to turn logging on and off, and provides useful tools for downloading and viewing the error log.
Get started with the new Gutenberg editor here.
The error log doesn’t tell you everything that happens on your site. If you’re interested in logging comprehensive information about what your site is doing and what users are doing on your site, you need a plugin such as WP Security Audit Log.
WP Security Audit Log logs a huge range of information, including changes to posts and pages, user accounts, settings, the database, and more.Posted in: Nexcess