Cara menggunakan wordpress turn off debug

Introduction

Do you need to enable debugging in WordPress? This doesn’t apply to only WPForms but when trying to debug anything on your site from any plugin or your WordPress theme.

When adding custom code such as PHP or JavaScript, there are times when you may need to find any possible errors in your code, your theme or other plugins or even on the server in general.

When enabled, WordPress debug will log any errors detected on your site. This can be key to finding the source of an issue or just learning more details about any possible errors on your site.

Enabling debug in WordPress

To enable debugging on your site, please follow the steps below.

1) Locating the wp-config.php file

By default, WordPress debug will be disabled. To enable it, you’ll need to access your site files through either an FTP (File Transfer Protocol) or your server’s cPanel.

To learn more about FTP, please check out this article from WPBeginner. Alternatively, our friends at WPBeginner also have an article on cPanel information, which you can view here.

Alternatively, you can also just install a plugin like WP File Manager to easily gain access to your server files through the WordPress admin area. To learn more about that plugin please check out their plugin on WordPress.org.

2) Editing the wp-config.php file

Once your site files are open, you’ll need to open wp-config.php for editing.

This file will be located in the root folder on your server. To learn more about the location and directory instruction, please review this article.

Cara menggunakan wordpress turn off debug

This file contains site-specific configuration settings, such as database information and, potentially, settings added by your hosting provider. For debugging, you’ll need to find this line of code (will generally be near bottom of file):

('WP_DEBUG',false);

3) Adding your debug code

Copy and paste this code snippet over the line of code mentioned in Step 2.

// 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
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define( 'SCRIPT_DEBUG', true );

This code will need be to inserted before the comment

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

in the wp-config,php file.

Cara menggunakan wordpress turn off debug

This will enable debugging and, importantly, prevent any logged data from displaying on your site. Instead, a debug log will be saved to your site files.

4) Replicating the issue

After saving these changes to wp-config.php, you’ll need to return to your site and replicate the issue you saw earlier. This will ensure that it gets recorded in the new error log.

5) Viewing the debug log

Then, you can return to your site files and open https://yoursitename.com/wp-content/debug.log.

Please know that the URL to the debug.log will depend on exactly how your site is set up. For example, if your site is installed in a subdirectory, the main URL may look like something like this: https://yoursitename.com/your-subdirectory-name/wp-content/debug.log. Check with your hosting company if you’re unsure how to access this file.

The contents of an error log can vary a lot depending on the cause and number of issues, but now you should be able to see extra details, such as a file path to the source of a code error, to help you better track down the issue.

No one starts off programming with a love for debugging. It is a source of endless frustration and dread. A lot of you wonder how many hours you would have to spend debugging. You’d much rather spend time building something cool.

That said, a good developer will never consider debugging as unimportant. It is an invaluable source of learning and growth. But debugging in the absence of a supporting environment is a developer’s nightmare. Thankfully, WordPress does provide efficient mechanisms to make debugging easy.

This article is about enabling WordPress debug tools. It’ll help you fix issues faster.

But before we get into the thick of things, for the uninitiated, here’s a short paragraph on what debugging means in the context of WordPress sites.

What is WordPress Debugging?

Debugging is the process of searching and removing errors from a piece of code.

While writing code, the developer makes mistakes just like you’d make spelling and grammatical mistakes when typing out an email. In the coding world, going back and correcting those faults is called debugging.

WordPress offers an easy way to debug faults and errors made by plugin and theme developers. But the debugging is disabled by default. You can enable it to fix malfunctions, incompatibility issues, etc. Let us show you how.

WordPress offers an easy way to debug faults and errors made by plugin and theme developers. Click To Tweet

How To Enable or Disable Debugging in WordPress?

Before you begin…

For debugging in WordPress, you’ll need to edit WordPress files. That’s risky. One fatal error could cause your website to break. It’s best to take a complete website backup so that you can restore your site back to normal when something goes wrong.

To enable or disable WordPress debugging, you’ll make edits in the wp-config.php file. Be careful with the file because it is one of the most important files on your website. It’s used to improve security, enhance performance, configure database functionalities, among other things. Making the slightest of mistake could make your website inaccessible (recommended read – Securing wp-config File).

Enable or Disable Debugging Mode Manually

To enable debugging mode in WordPress, follow these steps:

1. Log into your hosting account and launch File Manager.
2. In the public_html folder, find and open wp-config.php.
3. In the wp-config file, you’ll find the following line of code –

define(‘WP_DEBUG’, false);

The WordPress debug mode is now disabled. To enable it, you’ll have to replace ‘false’ with ‘true.’ It looks like this –

define(‘WP_DEBUG’, true);

Save the changes and exit the editor.  You have now enabled WordPress debugging mode.

Cara menggunakan wordpress turn off debug
Debugging mode is now enabled

To disable the mode, all you have to do is change ‘true’ to ‘false.’

There are more WordPress debugging options with which you can resolve many issues. Let’s looks at those options.

Enable or Disable Debugging Mode With a Plugin

There are many plugins in the market that make debugging WordPress really easy for you, WP Debugging is one such plugin. It will automatically set the debugging options to true.

To disable the settings, just deactivate the plugin.

Cara menggunakan wordpress turn off debug
WP Debugging dashboard

Other WordPress debug plugins that you can try out are Query Monitor, Debug Bar, and Log Deprecated Notices.

Additional WordPress Debugging Options

To make the process of debugging more efficient, WordPress offers a few other options. You can enable them whenever required. Here’s how to access additional debugging options offered by WordPress –

To Examine Errors On Your Site

If you’ve been using WordPress for a long time, you must have come across the White Screen of Death! It’s when your website shows blank pages. This is an error that is caused by a fault in the code among other things.

A WordPress website makes a note of such errors and stores them in a file. Luckily, you can access the debug logs by placing the following code in wp-config.php:

define(‘WP_DEBUG_LOG’, true);

Note: To get the WordPress debug logging file, you’ll have to have the WP_DEBUG set to true.

After saving the code, head over to your hosting provider account and launch your File Manager. The log file is typically present under the public_html folder.

Decompressing Files & Checking Errors

From search engines to visitors, everyone hates slow websites!

To make websites run faster WordPress compresses certain files to reduce the size of the files. In the process, some files are hidden which becomes a pain when developers are looking for an php error to debug an issue.

So what you need to do is decompress the files by adding the following script to your wp-config file:

define( ‘SCRIPT_DEBUG’, true );

To Prevent Displaying Errors On Your Site

When you are debugging a WordPress website, error and warning messages appear on your website. But the error messages could make your website look like it’s broken and reliable. If you want to ensure that those messages are not appearing on your website disable the option.

Place the following code in the wp-config file:

define( ‘WP_DEBUG_DISPLAY’, false );

Note: For the above code to work, you’ll have to have the WP_DEBUG set to true.

To Examine WordPress Database Errors

WordPress stores all your website content in a database. If a website is experiencing database issues, you can enable a setting that will help you identify those issues.

Add the following code to your wp-config.php file:

define( ‘SAVEQUERIES’, true );

Setting the ‘SAVEQUERIES’ to ‘true’ will enable you to send a database query in order to access the information stored in it.

Note: You can’t enable SAVEQUERIES, if you didn’t set WP_DEBUG to true.

Cara menggunakan wordpress turn off debug
Enabling all of WordPress debugging options

With that, we have covered all the options WordPress offers to help developers debug WordPress issues on a WordPress website. But before winding up, there’s one important thing to consider.

Taking notes is not everyone’s cup of tea. But experience tells us that in the world of coding when a problem occurs, it’s very likely to reoccur. Maintaining a solution log makes it easy as well as fast to find a solution to a problem that is reoccurring.

Conclusion

While debugging is not something many developers enjoy doing, it’s an important piece of work. The good news is that WordPress provides a support environment to perform debugging. The bad news is that debugging WordPress often has an impact on your website performance. It’s best to avoid doing it on live sites and use a staging website instead with the help of your web host or WordPress staging plugin.

Akshat is the Founder and CEO of BlogVault, MalCare, and WP Remote. These WordPress plugins, designed for complete website management, allows 100,000+ customers to build and manage high-performance websites with ease.