While WordPress is relatively easy to manage, troubleshooting errors are a fairly common problem for its users. Dealing with them is usually not difficult – all it takes is a little practice. The first step in every WordPress error troubleshooting is to get the error log.
The error log contains all errors, warnings and notifications related to the code behind your site. Sometimes it can help you identify the exact file and line of code causing the problem. The error log can also provide clues for resolving seemingly unresolved errors such as the “white screen of death”.
However, the error log can be quite difficult to understand if you are not tech savvy. To be tech savvy you have to start somewhere – so let’s start by showing you how to open and retrieve error logs in WordPress.
How To Set Up WordPress Error Logs In Your WP-Config File
The wp-config.php file is an important WordPress configuration file. By editing it a bit, you will enable WordPress default debugging and show errors. You can do this via an FTP client or cPanel.
Using FTP Client
A prerequisite for making any edits to your server files is to set the file permissions correctly. The recommended permissions for the wp-config.php file are 440 or 400. This means you are only allowed to read files. To get an error log, you need to temporarily change the file permissions to 644 or 666. For clarification, 644 gives administrative users read and write/edit permissions while other users only have read permissions. A value of 666 grants all users both permission types mentioned above.
You need an FTP client and knowledge of editing the wp-config.php file to continue. Start by connecting to the server using your FTP credentials. go to your address root wordpress directory. find wp-config.php fileright click on it and “File permissions” option.
Manually enter one of the suggested numeric values (644 or 666) and click “OK”.
After changing the permissions, go back. root directoryright click wp-config.php file and “Edit View”.
Open the file using a text editor and add the following line of code:
define('WP_DEBUG', true);
/* That’s all, stop editing! Happy blogs. */.
if define('WP_DEBUG', false); line already exists, just turn wrong into right.
Save the changes and upload the edited file to your root WordPress directory. This will override the file currently on your server.
via cPanel
You can also use cPanel to edit the wp-config.php file. Login cPanel using your credentials and “File Manager”.
go to: root directory Your WordPress installation on the left wp-config.php fileright click and “Change Permissions”.
Be sure enable both read and write permissions by ticking the appropriate checkbox for the (administrator) user. Next, “Change Permissions”.
Then right click wp-config.php file once again andTo organise”.
The file opens in the default cPanel editor, so just add define('WP_DEBUG', true); above /* That's all, stop editing! Happy blogging. */ The line of code inside the wp-config file.
If the file already contains the following line define('WP_DEBUG', false); just change the value from false to true and click “Save Changes” in the top right corner of your screen.
How to Manage Displaying Errors
When you successfully view the errors, they will show on your pages both in the backend and the frontend. If your site isn’t in development, it’s not a good idea to live stream bugs clearly. Instead, you should save them as a single file and hide them from your site. This allows you to view the file later and fix errors whenever you want.
To do this, add this code to your wp-config.php file.
define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); @ini_set( 'display_errors', 0 );
Add the code below the line below define('WP_DEBUG', true); and above /* That's all, stop editing! Happy blogging. */ code line.
You can edit the file using an FTP client or via cPanel by following the steps we outlined in the previous section. After editing your wp-config.php file should look like this.
define( ‘WP_DEBUG_LOG’, true ); we force WordPress to store all error messages in a single file. By default, this file is called debug.log and is located in your -WordPress-root/wp-content/ directory. You can also store error messages in another file that you create. In this case, “define(‘WP_DEBUG_LOG’, true );” replace the true value. to the path of the file. E.g:
define( 'WP_DEBUG_LOG', path-to-your-site/wp-content/error.log );
Besides, WP_DEBUG_DISPLAY determines whether error messages are displayed on the screen.. define( ‘WP_DEBUG_DISPLAY’, false ); you tell WordPress to hide the messages from your screen, but they will still be printed to the specified file. if you too @ini_set(‘display_errors’, 0 ); add this will disable error printing for your PHPmaking sure users won’t be able to see them on the frontend.
Getting the Error Log
With errors shown and successfully written to the appropriate error log file, all that remains is to review the error messages and take further steps.
Manually Downloading the debug.log File
Connect to your server to download the log file, root wordpress folder and click on wp content. Find debug log file inside, right click Press and “download”.
Save the file to your desktop. Then make sure to undo previous edits. This includes removing the code you added and changing the permissions in the wp-config.php file to 440 or 400. You can do this after you’ve fixed the errors if you want.
Finally, open the saved debug.log file with a text editor and check the error messages written. Depending on your level of expertise, you can fix bugs yourself or hire a developer.
More Advanced Debugging Features
We’ll also take a look at some of the more advanced debugging possibilities. The code below should be added to the wp-config.php file above the code below. /* That's all, stop editing! Happy blogging. */ liner.
define(‘SCRIPT_DEBUG’, true);
This code forces WordPress to use unminified versions of CSS and JS files.especially useful for debugging changes and/or errors found in your CSS and JS files.
define(‘CONCATENATE_SCRIPTS’, false );
By setting the CONCATENATE_SCRIPTS constant to false, WordPress to install all scripts separately. This can be useful for locating bad/incompatible scripts.
define(‘SAVE’, true);
If you’re experiencing database problems, analyzing the queries run is a good way to start debugging. Adding the above code In $wpdb->queries array put query content which function called and for how long. This will allow you to dig deeper into the backend part of the theme code and what exactly it does.
then you can add the following code to show all the queries in a readable format and analyze them.
global $wpdb;
print("<pre>".print_r($wpdb->queries,true)."</pre>");
However, keep in mind that this code will affect your site’s performance, so we recommend that you use the code for debugging purposes only.
final thoughts
By following this guide, you can show and securely store error logs in a file, change file permissions, and run some debugging features for more advanced WordPress users. This tutorial will also help you learn more about the way your website works – so keep it close as you may need these instructions in the future.
Support our work ❤️
If you enjoyed this article, consider leaving a tip to help us keep publishing great content.


























