How to use WordPress logs to fix errors

Last Updated On
Photo of author
Written By WPCubicle Team

If you are here, you’ve probably noticed an error on your website and are trying to troubleshoot it. Maybe after your admin WordPress login, you saw a message saying your website is experiencing technical difficulties? Or (horror of horrors!), the dreaded white screen or blank screen error.

Whatever the problem, WordPress logs can be very useful in narrowing down the possible reasons for an error.

It really doesn’t matter whether you are a developer or not. If you are able to do this basic troubleshooting, it will at least help you to identify the correct plugin or theme that is causing the error. You can then directly contact the developer of that plugin, possibly sharing the error messages as well, and have this sorted out quickly.

So keep calm and jump right in…

How do I check my WordPress logs for errors?

You need to first enable your WordPress logs, before you are able to access them – because these logs are turned off by default.

You will need to turn on the WordPress debugging mode , so that all errors that are generated on your website get captured in a log file. This can be done by editing a file named wp-config.php.

Find the WP Config file

Every WordPress installation has a WP Config file. This WP config file contains all the important information related to your WordPress environment and database set up. This file is usually located in the main, root folder of your WordPress installation. If you have direct access to your files, then use either CPanel or a FTP client tool like FileZilla, to find this file.

Edit the WP Config file

Read this note before you start: It is best to edit this file using the default editor that is available in the tools that you use to locate the file – i.e .CPanel or a FTP Client. If you choose to download and edit the file locally, then please remember, you should never use a Word Processor tool like Microsoft Word or Google Docs etc. If you haven’t done this before, I recommend you read this list of editing tools to avoid and this list of text editors that you can use to edit this file.

Now, look for this line that already exists in the wp-config.php file.

/* That’s all, stop editing! Happy blogging. */.

and insert the code snippet below just above this line

// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );

// Disable display of errors and warnings on your website
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

If any of these lines already exist with different values, then simply update the values. For example, if you can already see a line like this in your file, the ‘FALSE’ value means debugging is turned off. Simply change it to ‘TRUE’.

define( 'WP_DEBUG', FALSE );

Find your WordPress Error Logs

Now that you have enabled debugging on your website, you should open the error logs and find out what’s wrong.

Access your WordPress installation files via CPanel or FTP and look for a folder named wp-content. You should see a file called debug.log within this folder.

Remember though, that you will need to replicate the steps that caused an issue on your website, so that the error messages get captured in your newly created log. There’s no way for the log to retrospectively retrieve any errors that may have been generated in the past.

Using the WordPress logs to resolve the error

If you are able to figure out the root cause using the messages in the error logs then great. Else you could try one of these options

  • Google search the error message to see if there is a known fix
  • If the error message gives you some idea about the plugin or theme that is causing the issue, then you can send the error log to the plugin / theme developer and ask for support.
  • You can head over to the WordPress forum and see if someone can help you narrow down the problem.

Be sure to include the error messages from your WordPress logs when you reach out to anyone for help.

WordPress Support Forum for help with WordPress logs

WordPress Support Forum is manned by volunteers who are happy to help out anyone in need.

Important : Turn off WordPress Debug Mode

After you are done identifying the issue, you need to turn off debugging. Logging error messages continuously on a live website can slow down the performance.

To disable debugging in WordPress, simply change the values in the earlier two lines in wp-config.php from true to false.

// Disable WP_DEBUG mode
define( 'WP_DEBUG', false );

// Disable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', false );

Frequently Asked Questions about WordPress logs

Does WordPress have log files?

Yes, WordPress gives administrators the ability to generate error logs – but these are turned off by default and need to be enabled. You can even generate activity logs (audit trail) using a WordPress plugin like WP Activity Log.

How do I enable WordPress logs?

If you want to fix an error on your website and are trying to look into the possible causes, you will need to enable WordPress error logs. This is done by turning on the debugging mode.

Where can I find WordPress logs?

If you have turned on debugging, then a file debug.log is usually created in the wp-content directory.

Photo Credits : Featured Image by fancycrave1 from Pixabay

Leave a Comment

Signup to WPCubicle's Newsletter (1 Email a Month)

* indicates required