Home Blog WordPress Management WordPress debug: how to enable it & debugging options

How to enable WordPress Debug

WordPress debug: how to enable it & debugging options

Sometimes we are unable to reproduce a problem that a user is encountering when using one of our WordPress plugins. When this happens, we ask the user to send us more information about their website’s and plugin’s setup.

Such information is typically found in a log file, more specifically, the WordPress debug log file. This log file can be generated by enabling the WordPress debug mode. In this post, we’ll dig into the built-in WordPress debug mode and show you how to enable it. Then, we’ll also share some additional WordPress debugging options.

Here’s what we’ll cover:

  • Introduction to WordPress debug mode
  • How to enable WordPress debug mode
  • Additional WordPress debugging options
  • Does WordPress debug mode affect the performance of your website

What’s the purpose of WordPress debug?

In case of present issues on your website, the WordPress debug mode can help you discover what is going wrong on your website. It does so by reporting all errors, warnings and notices. All of these are shown in the UI and can also be redirected to a log file.

Note that debugging is disabled by default on WordPress and it should only be enabled temporarily to troubleshoot issues. WordPress debug should not be permanently enabled on live websites because it will affect the performance of the plugin and possibly disclose sensitive information about the website that can be used maliciously.

Enabling WordPress debugging

To enable the WordPress debug mode and the debug log file follow the below procedure:

  1. Enable WordPress debug by setting the WP_DEBUG switch in the wp-config.php file to true, as per the following example: define( ‘WP_DEBUG’, true );
  2. Enable the debug log file by adding the following line to the wp-config.php file: define( ‘WP_DEBUG_LOG’, true );

The WordPress debug log file is called debug.log and it is created in the /wp-content/ WordPress subdirectory.

Once you enable debugging, reproduce the issue so the error is captured in the log file. After you reproduce the issue, disable the debugging by setting both the WP_DEBUG and WP_DEBUG_LOG directives in the wp-config.php file to false, as per the below:

define(‘WP_DEBUG’, false);

define(‘WP_DEBUG_LOG’, false);

Additional WordPress debugging options

Most probably we will never ask you to use these options, but it is good to know about them as well. Apart from the above mentioned ways to debug, you can also use the following WordPress debugging methods:

WP_DEBUG_DISPLAY

When this option is enabled alongside the WordPress debug switch, WordPress shows the debug messages in the HTML pages as they are generated.

Note that if this is used on a live website this could lead to the disclosure of sensitive information about the website and server setup. To enable this option, add the below line to your wp-config.php file:

define( ‘WP_DEBUG_DISPLAY’, true );

SCRIPT_DEBUG

When this option and WordPress debugging are enabled, WordPress uses the development versions of core CSS and JavaScript files instead of the minified (compressed) version that it normally uses.

This debugging option is useful if you are testing changes in .js and .css files. To enable this option add the below line to your wp-config.php file:

define( ‘SCRIPT_DEBUG’, true );

WP_DEBUG_LOG

Use this to change the path of where the debug log file is saved. By default it is saved in the /wp-content/ directory on your WordPress website.

define(‘WP_DEBUG_LOG’, ‘/path/outside/of/webserver/root/debug.log’);

Logging of WordPress database queries

On WordPress, you can also keep a log of the WordPress database query in an array. This option comes in handy if you are experiencing WordPress database issues, or you want to check what queries are being sent.

To enable it, add the following line to your WordPress wp-config.php file:

define(‘SAVEQUERIES’, true);

Once you enable this option all queries will be saved in the $wpdb->queries global.

Does debugging affect the performance of my WordPress website?

Yes. Some debugging options can have an impact on the performance of your website. Therefore, unless it is a test or staging website, or you’re instructed to temporarily enable debug by developers do not enable debugging on live websites.


Leave a Reply

Your email address will not be published. Required fields are marked *

Stay in the loop

Subscribe to the Melapress newsletter and receive curated WordPress management and security tips and content.

Newsletter icon

It’s free and you can unsubscribe whenever you want. Check our blog for a taste.

Envelope icon

Gain insights into your WordPress sites like a pro with our comprehensive guide to WordPress oversight

Close
The Ultimate Guide to WordPress Oversight

 Boost your sites’ security and management! Download our free eBook on WordPress oversight.

Uploading WP 2FA as a zip file in WordPress
WP 2FA in the WordPress plugin repository
Close

Installing WP 2FA Free

Congratulations on taking the first step towards enhancing your WordPress site's security with WP 2FA Free! You're now on your way to protecting your valuable data and ensuring peace of mind. No coding or technical knowledge is required.

 

Below are two ways to install WP 2FA on your website:

Go to your plugin dashboard on your site, then go to "Add New", and then search for WP 2FA.

Download the WP 2FA plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading CAPTCHA 4WP as a zip file in WordPress
CAPTCHA 4WP in the WordPress plugin repository
Close

Installing CAPTCHA 4WP Free

Well done you. You're one step closer to safeguarding your WordPress website from spam and automated attacks with CAPTCHA 4WP. You'll be able to effortlessly integrate CAPTCHA into your forms and enjoy a website with enhanced security.

 

Below are two ways to install CAPTCHA 4WP on your website:

Go to your plugin dashboard on your site, then go to "Add New", and then search for CAPTCHA 4WP.

Download the CAPTCHA 4WP plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading WP Activity Log as a zip file in WordPress
WP Activity Log in the WordPress plugin repository
Close

Installing WP Activity Log Free on your website

You deserve a pat on the back for choosing to record user actions and changes on your website. That is the first step towards better user accountability, easier troubleshooting of website security, and many other benefits of issues.

 

Below are the two ways to install WP Activity Log on your website:

Go to your plugin dashboard on your site, then go to "Add New" and then search for WP Activity Log.

Download the WP Activity Log plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading Melapress Login Security as a zip file in WordPress
Melapress Login Security in the WordPress plugin repository
Close

Installing Melapress Login Security Free

Congratulations on taking control of your WordPress website's security by implementing robust login and password policies with Melapress Login Security. You can change your login page URL, limit failed login attempts, and reset passwords.

 

Below are two ways to install Melapress Login Security on your website:

Go to your plugin dashboard on your site, then go to "Add New" and then search for Melapress Login Security.

Download the Melapress Login Security plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2