WordPress

How Do I View WordPress Error Logs?

This tutorial explains how to enable and view WordPress error logs.

In some cases, reading WordPress error logs is mandatory to identify a problem in your site. This tutorial will show you how to do it easily.

All steps described in this tutorial include screenshots to make it easy for all users to follow them.

To enable WordPress error logs, you need access to your server through FTP, SSH or your hosting provider Cpanel/Plesk. In this article I show you how to do this both through Cpanel and through FTP.

View WordPress Error Logs from Cpanel

To begin access your hosting root directory, where your site is hosted using Cpanel, FTP or Plesk, and find the file named wp-config.php which we need to edit to enable debugging.

If you are using Cpanel, once the file is identified, right click it and press the Edit option.

If an encoding warning shows up, press the Edit button again to access the file.

Find the following line almost at the end of the file.

define( 'WP_DEBUG', false );

Remove it and paste the following lines and then press the Save button to apply changes.

define( 'WP_DEBUG', true );

define('WP_DEBUG_LOG', true);

define('WP_DEBUG_DISPLAY', false);

@ini_set('display_errors',0);

After pasting that code, you can find a new file named debug.log located within the wp-content subfolder in your hosting.

In some cases, users reported the debug.log file wasn’t created, but they found a file named error_log within their root directory. If you still want the debug.log file to be created instead of the error_log file, you can rename it and the debug.log file will be created.

Note: Some plugins like Wordfence will prevent the debug.log file from being created, you need to disable it until you finish the debugging process.

All error logs will be saved in your debug.log or error_log files depending on what file is created in your case.

Of course, in many cases, the user won’t understand the log information, but it is great data you can use to realise the specific cause of an error using a search engine, just copy paste last lines related to your issue.

In my case, the errors are reporting an old PHP version.

View WordPress Error Logs Using FTP

If you are using an FTP client and want to enable error logs in WordPress, connect to your hosting, as shown below.

Note: In this tutorial, I’m using the Filezilla FTP client.

If a certificate approval request shows up as shown in the following image, press the OK button.

Enter into the public_html directory, the root directory of your website.

Find the file named wp-config.php.

Right click the file wp-config.php and download it.

Once downloaded, almost at the end of the file, find the line containing the following:

define( 'WP_DEBUG', false );

Replace the line mentioned previously with the following lines as shown in the screenshot below the code.

define( 'WP_DEBUG', true );

define('WP_DEBUG_LOG', true);

define('WP_DEBUG_DISPLAY', false);

@ini_set('display_errors',0);

Then, upload the modified file to your site root directory.

Overwrite the existing wp-config.php file.

Now the debugging mode is enabled, and you can check the debug.log file under the wp-content directory to read WordPress error logs.

Conclusion

As shown in this tutorial, enabling and reading WordPress error logs is easy as long as you have access to your hosting files. Knowing how to enable the debugging mode to read logs is mandatory for any WordPress administrator in order to afford possible unknown problems.

If you have access to your server, you can use the methods explained in this tutorial, or other methods like SSH as explained in the introduction of this article. I hope this work was helpful for you to solve any inconvenience with your WordPress site.

Thank you for reading this WordPress tutorial explaining how to read error logs. Keep following us for more WordPress tips.

About the author

David Adams

David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.