Sometimes we are unable to reproduce a problem that a user is encountering when using the WP Activity Log plugin. In such cases we would require more information from the user’s WordPress website, which can be found in a log file. These log files 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 of 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, WordPress debug mode can help you discover what is going wrong by showing all errors, warnings and notices.
Note that debugging (the process of finding and resolving issues in a software) is disabled by default on WordPress and should not be permanently enabled on live websites. It should only be enabled temporarily to troubleshoot issues.
Enabling WordPress debugging
When we ask you for the debug log file you should:
- 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 );
- Enable the generation of the debug log file by adding the following line to the wp-config.php file:
- define( ‘WP_DEBUG_LOG’, true );
By default, the WordPress debug log file is called debug.log. It is created in the /wp-content/ WordPress subdirectory.
Once you enable the 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:
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:
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 );
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 );
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:
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, such as the logging of database queries, can have a very big 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.
You should only enable debug when necessary and temporarily, to troubleshoot a specific issue.
The post WordPress debug: how to enable it & debugging options appeared first on WP White Security.
*** This is a Security Bloggers Network syndicated blog from WP White Security authored by Radostin Angelov. Read the original post at: https://www.wpwhitesecurity.com/complete-guide-wordpress-debug-mode/