How to Set Up WordPress Error Logs In wp-config.php File For Your Website ?

How to Set Up WordPress Error Logs In wp-config.php File For Your Website ?

Are you finding it difficult to check for WordPress errors in errror_log.php file in root directory like public_html. If you are also using some custom script other than WordPress in your website it becomes extremely to find out which of the errors are from WordPress and which are from other scripts. It will be convenient if we could find a way to display WordPress errors at a different location. This can be done by setting up WordPress error logs in wp-config file? The wp-config file controls your WordPress site settings, it can also be used as a debugging tool to find and fix the errors. Let’s see how to set up WordPress error logs in the wp-config file. Before that, let’s have look at what is Error log and its importance.

What is Error Logs :

Error log is the collection of error which comes while execution of your website code. Most of the servers generate this file automatically and store a log of all the Errors and warnings comes. Some errors and warnings are not fatal in nature and the website keeps running fine. But sometimes the website fails to load or through some error during the execution of a particular script like form submission etc, then we need to look for this file in the file manager. Usually, it is available in the public_html folder but it can be the respective WordPress installation directory also.

Importance of Error Log in WordPress Website :

Error Log file is very important in a situation when your site doesn’t load at all. Error log is the only place where you can get to know about the issue. It provides you the completed picture of the issue. Using this you can resolve the issue easily which wouldn’t be possible otherwise.

How it is useful to Set up WordPress Error logs in wp-config file –

wp-config file is very important file as it controls the high level setting of a WordPress website. Following setting are usually done in wp-config file :

  1. Setting up database parameters like Database name, DB Username & Password. You can also setup the table prefix of the database, charset and collate type.
  2. Setting up various keys like Auth keys, Nonce key, Auth Salt etc.
  3. Enable or disable several parameter like the Debug mode, disallow theme and plugin edit etc.

The last point is used for setting up the WordPress Error Log in wp-config file. By setting up this you will easily be able to check the error log of various themes and plugins used in your website. Then you can easily find and fix the error.

Finally Setting up the WordPress Error Logs in wp-config file

If you check your wp-config.php file you will find a following section of code just above the “Happy Blogging” line –

/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the Codex.
*
* @link https://codex.wordpress.org/Debugging_in_WordPress
*/
define(‘WP_DEBUG’, false);

By default he Debug mode is disabled. You can turn it on by changing false to true.

How you can edit wp-config will depend upon the access you have :

1. If you have cPanel access –

a. Open the File manager in cPanel

b. Go to WordPress installation directory.

c. Look for wp-config.php file and open it in edit mode.

d. Search for define(‘WP_DEBUG’, false);

e. Change the value false to true.

f. Save the file and its done.

2. If you have FTP access only – 

a. Open you FTP account using a FTP client like FileZilla.

b. Reach to the WordPress installation directory and look for wp-config.php file.

c. Download this file wp-config to edit it on the local system.

d. Open the wp-config file in editor and search for define(‘WP_DEBUG’, false);

e. Change the value false to true.

f. Save the file and upload it back.

Check the result of this setup of WordPress Error Logs in wp-config file –

To check the result open the file manager either in cPanel or FTP account as per the access you have. Go to wp-content folder and look for file debug.log . This is the file where you will find the WordPress error logs.

As we earlier discuss about the importance of Error Log, if you want to be a complete developer you should be able to make good use of the error message given by the server and system to resolve the errors. Let us know in commets if you faced any such error in past and solved it. If it is still unsolved, do let me know in comments so we can find its solution.

 

If you like above article, please subscribe. We will keep you updated with our new Articles.

Leave your Feedback / Questions in Comments.

Leave a Reply

nine + six =

Close Menu