As error logs in WordPress provide valuable information about issues and help you fix problems more efficiently, finding and accessing these WordPress error logs is important.
The entire process is defined as enabling debug mode in WordPress, but before that; let’s first understand what different debugging snippets do for you:
Functioning of Debudding Mode Variables
As there are four different variables that get added to the wp-config file to enable debug mode, understanding how each of those works is important so that can enable them accordingly.
define( ‘WP_DEBUG’, true );
WP_DEBUG is a PHP constant (a permanent global variable) that enables the ‘debug‘ mode throughout the entire WordPress site.
When you start editing this file, the code snippet must be set to ‘define( ‘WP_DEBUG’, false);’ which you’ll need to replace with the code mentioned in the ‘Editing and uploading the wp-config file‘ section below.
By enabling this – all PHP errors, notices, and warnings will be displayed. Due to its standard behaviour, these error messages are shown on the main web page or on the white screen of death.
Not to worry, we will help you with code snippets that will create a bedug.log file instead of messing up the website due to such errors.
define( ‘WP_DEBUG_LOG’, true );
It helps you to collect all errors, notices, and warnings, and save them in a log file named debug.log. By using this, reviewing and fixing errors gets way easier and also gives you a free hand to correct them later.
define( ‘WP_DEBUG_DISPLAY’, false );
It allows you to control whether you want to show the debug messages on the particular HTML pages or not. We suggest setting this to false only, as enabling this to true will affect the page crawling and SEO rankings.
define( ‘SCRIPT_DEBUG’, true );
SCRIPT_DEBUG is an associated constant that compels WordPress to utilize the ‘dev’ version of core CSS and JavaScript files instead of the compressed files. This proves advantageous when evaluating alterations to any pre-existing .js or .css files.
Enable WordPress Debug Mode via SFTP/FTP
If you’ve accomplished such technical approaches before, you must be familiar with the FTP (File Transfer Protocol). SFTP/FTP is just a secured version of it, which stands for Secure File Transfer Protocol and adds a safeguarded layer to the file transferring process. Here you go with the steps:
Connect to the Website via SFTP/FTP
If your SFTP/FTP access has yet to be requested, you’ll need to enable it first.
Navigate to My Site(s) → Settings → Hosting Configuration.
Click on the Enable SFTP/FTP button.
You’ll receive details, including host, username, password, and port.
Connect with SFTP/FTP software such as FileZilla using the same credentials.
Navigate and Download the wp-config File
From the root folder of hosting only, you’ll get the wp-config.php file. Alongside folders such as wp-content, wp-admin, and wp-includes.
Download the wp-config.php; here are the best IDEs for PHP development you can use to edit it. Also, download a copy of the same file so that an unintentional snippet code error occurs; you can use this copy file as a backup.
wpconfigfile-in-sftp
Editing and Uploading the wp-config File
Enter the code snippet mentioned below, BEFORE /* That’s all, stop editing! Happy blogging. */:
// 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 );
view rawEditing and uploading the wp-config file hosted with ❤ by GitHub
Save the file and go to the web-connected SFTP/FTP server.
Delete the currently uploaded wp-config file first, then upload the edited file on which we mentioned the above code.
You are done there!
Access to WordPress Error Logs
Navigate to the wp-content folder. If there is any error on your Website, you’ll find a new file named debug.log – in which every error and alert will be mentioned.
You can download that file on your computer, check out the mentioned issues, and figure them out simultaneously.
Enable WordPress Debug Mode via Web Hosting
Go to Cpanel → File Manager.
In the root website folder → wp-config.php file.
Right-click on the wp-config.php file and tap on edit.
Enter the code snippet mentioned below, BEFORE /* That’s all, stop editing! Happy blogging. */:
// 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 );
view rawEditing and uploading the wp-config file hosted with ❤ by GitHub
This will turn on WordPress debug mode.
You can access your WordPress error logs with the file named debug.log in the wp-content folder.
Enable Debug Mode Using WP Debugging Plugin
Enabling error logging using a plugin is the best for both technical and non-technical, as you don’t redirect to any WordPress hosting panel to check on the errors.
Moreover, its reports also get updated whenever an error occurs or is about to trigger any error. Some of the popular WP debugging plugins are Akismet Anti-Spam, Health Check & Troubleshooting, and WP Debugging.
Akismet Anti Spam Plugin Setup :
Navigate to WP Admin Panel → Plugins.
Tap on Add New → Type Akismet Anti Spam.
Click on Activate.
To complete the setup process, it will ask for an API.
By keeping the window open, Visit Akismet’s official Website.
Tap on ‘Get Started With Akismet’, and pick the best fitting plan for you.
Once you are done with that, fill out the required information. Afterwards, you’ll receive an email for verification purposes – once you are done with that, you’ll get access to your Akismet dashboard and API key, too.
Copy the API key, come back to the WordPress dashboard, and navigate yourself to the plugins Akismet setup.
Under Akistment, tap on Setting. It will respond with a setup process pop-up.
Paste the API key, tap on connect with the API key and the Save Changes in the last step
Health Check & Troubleshooting Plugin Setup:
Navigate to WP Admin Panel → Plugins.
Tap on Add New → Health Check & Troubleshooting (By The WordPress.org community).
Install and click on Activate.
Go to the Plugins page. Under the Health Check & Troubleshooting plugin, you’ll see a ‘troubleshoot’ option.
To enable this debug mode, go to Tools → Site Health → Troubleshooting and click on Enable Troubleshooting Mode.
After troubleshooting has been enabled, you’ll be redirected to a panel from where you can fix errors on your site by enabling one plugin at a time or by switching to a different theme.
WP_Debug Plugin Setup:
If configuring WordPress error logs in the wp-config file is too complex for you; you can do the same by using the plugin and avoid editing any core files from the control panel. Here you go with the steps:
Navigate to WP Admin Panel → Plugins.
Tap on Add New → WP Debugging.
Install and click on Activate.
Navigate to the Dashboard → Tools → WP Debugging.
Tick the check box next to the “Set WP_DEBUG to true” option
Once you are done, click the “Save Changes” button.
Sign in to leave a comment.