If you’ve ever had a problem with your WordPress website that you’ve then Googled, you might have seen support articles that begin by advising you to ‘check your WordPress logs’. Equally, if you’ve ever asked your WordPress host for help, they themselves would have either a) asked for a copy of your logs or b) proactively accessed these themselves in order to help troubleshoot your issue. So, what exactly are WordPress logs and how would you go about using these to resolve issues with your WordPress website? Let’s find out!
What are WordPress Error Logs?
WordPress logs are quite simply a file that records actions that occurred on your website. Normally its the ‘Error Log’ that is of primary interest as this is where details of any problems that happened to your site are recorded. If your website was hit with dreaded ‘White screen of death‘ for example, you could check your error logs to see what had been recorded. Hopefully the data available would point you in the direction of the error and thus allow you to fix the issue. Clearly this is of huge help as without this data you are somewhat flying blind when it comes to ascertaining why something has gone wrong on your website.
As the screenshot of an Error Log shows above, an error was recorded in this particular website on 28th October and was caused by a call to an undefined function in a theme. The log even tells us which line of code caused the problem allowing the website user or hosting tech team to resolve this.
What Kind of WordPress Logs Are There?
It’s not just about Error Logs (although this is what this article is focussing on as they are the most commonly used log files). A whole range of logs are available to you and the information that is contained in these can be used to do a large number of things such as:
- Locate Errors on your website
- Help with troubleshooting those errors
- Auditing access to your website
- Monitoring plugin performance
- Track user activity
- And much more…
Once you’ve got used to accessing and reading logs you’ll find that it will become second nature to check these and utilize the information they contain. Logs are truly the unsung heroes of WordPress.
Enabling WordPress Debug Log Files
As we’ve now ascertained, log files (and in particular error log files) can be incredibly useful things to use. Weirdly though, these log files are actually disabled in most new WordPress installs. The reason? Logging everything that your WordPress website does uses a significant amount of server resources and, as for the most part this information isn’t needed, it makes sense to turn these off and in doing so, improve the performance of your website.
If you find you need to troubleshoot a problem on your website you’ll first need to enable what’s known as the ‘Debug Mode’. The standard way to do this is by accessing your
Note: Before undertaking any work on your website, please ensure you are either a) using a staging server to work on your site or b) have taken a suitable backup of your website.
To do this, log into your site via SFTP and head to your
/public_html/ folder. In this folder you will see a file called
Open this up using a text editor of your choice such as Sublime and scroll to around line 76. You should see some comment and potentially a line of code that reads
define('WP_DEBUG', false);. The full section of code including comments will look something like this:
/** For developers: WordPress debugging mode. Change this to true to enable the display of notices during development. It is strongly recommended that plugin and theme developers use WP_DEBUG in their development environments. */ define('WP_DEBUG', false);
To turn on the WordPress Debugging mode you will need to change the
false statement to
true so it reads
define('WP_DEBUG', true);. Now debugging is enabled we need to tell WordPress to generate the log file itself. To do this you’ll need to add in another line which reads
define('WP_DEBUG_LOG', true);. You will left with this:
/** For developers: WordPress debugging mode. Change this to true to enable the display of notices during development. It is strongly recommended that plugin and theme developers use WP_DEBUG in their development environments. */ define('WP_DEBUG', true); define('WP_DEBUG_LOG', true);
Now debugging mode is enabled and logs are being generated we just need to find them!
Finding Your Error Logs
Your shiny new debug log file will appear in the /wp-content/ folder and can be accessed via SFTP just as you would for any other file in your WordPress install. It’s important to note though that this file will ONLY appear when an error occurs. If everything is working perfectly then this file won’t be generated.
So, you now have a waiting game on your hands… if your website is really broken, then it won’t take long for an error to manifest itself and the log file will be generated. If the error is more obscure and only occurs intermittently then you’ll just have to be patient and wait for this to happen.
Host your website with Pressidium
60-DAY MONEY BACK GUARANTEE
When a log file is generated you can go ahead and open this with your text editor and begin reading. The contents might well be a little overwhelming but, even if you’re a beginner at this, there are normally clear clues as to what might be causing the problem. At this stage it’s then a case of rectifying the issue or handing the problem over to a developer or your web host (if it’s the kind of problem their support team will assist with).
IMPORTANT – When you have finished debugging your site, you must disable debugging mode. Leaving this switched on will consume server resources unnecessarily and slow your website down.
There are a couple of plugins that you might like to use to help with your debugging efforts that are recommended by WordPress.
Debug Bar is WordPress’s own plugin so you can be confident it’ll work well with your website. It adds a debug menu to the admin bar that shows query, cache, and other helpful debugging information. When WP_DEBUG is enabled it also tracks PHP Warnings and Notices to make them easier to find. It’s described as a ‘must’ for developers!
Query Monitor is described as ‘the developer tools panel for WordPress’. It enables debugging of database queries, PHP errors, hooks and actions, block editor blocks, enqueued scripts and stylesheets, HTTP API calls, and more.
As well as the above it includes some advanced features such as debugging of Ajax calls, REST API calls, and user capability checks. It provides the ability to narrow down much of its output by plugin or theme, allowing you to quickly determine poorly performing plugins, themes, or functions.
Error Logs and Debugging with Pressidium Hosted Websites
If your website is hosted with Pressidium you can view both access and error logs via the Dashboard. To do this, log into your Dashboard and head to a website install and then click on ‘Logs’. Bear in mind that you won’t see any Error logs recorded if there have been no errors on your website.
If you need further information you can enable the WordPress debug mode without having to edit your
wp-config.php file. Simply head to the settings panel and toggle the WP_DEBUG switch. Bear in mind that debug logs can contain a huge amount of information, much of it irrelevant to the task at hand. Because of the size of these logs you can fill up disk space very quickly and this can degrade the performance of your website. Because of this it’s vitally important that you disable the debug logs when you have finished troubleshooting.
WordPress error logs can be a real life saver and can quickly help you understand why something has gone wrong on your website. They can initially seem a little intimidating but once you get used to accessing and reading them you’ll come to enjoy the wealth of information they offer. Happy debugging!
Host your WordPress Website with Pressidium!