Enabling the WordPress Debug log

 

Overview

You can enable WordPress debug mode to record errors to a log file (/wp-content/debug.log) without displaying them on your live site. This article explains how to turn on WP_DEBUG and WP_DEBUG_LOG in your wp-config.php file via SSH or FTP, how to view the log, and how to use a debug plugin as an alternative.

Background

WordPress provides a debugging tool that helps you find the cause of any errors on your website. This tool can display information in two ways:

  • Live on your website — This is not recommended if your website is live to the public, but can be a quick way to troubleshoot an issue.
  • Create a debug log file — This creates a log file on the server to help you troubleshoot an issue.

How do I enable debug mode?

To enable debug mode:

  1. Log in to your server via SSH or FTP.
  2. Edit the wp-config.php file using SSH or your FTP client.
    The following line appears near the bottom:
    define('WP_DEBUG', false);
  3. Replace that line with these three lines:
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_DISPLAY', false );
    define( 'WP_DEBUG_LOG', true );

    It's not recommended to change WP_DEBUG_DISPLAY to true as this displays any errors on your live website.

    By enabling WP_DEBUG_LOG, you can view the same errors in your /wp-content/debug.log file instead.

When an error occurs in WordPress, it now writes to a file titled debug.log, located in your /wp-content/ directory. Open this file using SSH or your FTP client to view the debug report.

How do I view the debug log with a plugin?

You can also use a plugin to help you debug your site and view your debug log. See this article for information on how to manage and install a plugin. When searching for a plugin, try typing in debug as a search term, as there are many different options for you to choose from.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?