In this lesson, we show how to enable Error logs on the WordPress site using the wp-config.php file. The wp-config.php file in the root directory of your WordPress site is not just a set of settings and configurations. It is also a useful tool for debugging, with which you can identify potential errors on the site.
The wp-config file contains basic parameters and settings for your site on WordPress. It stores such important data as connection settings to the database, a prefix for the database tables and an address for logging into the admin area if WordPress is installed in a subdirectory.
But besides the basic settings, wp-config can also be used to set other parameters. For example, we can enable debugging mode (wp_debug) and write all the received data to the error log (error log).
In most cases, this helps to identify and fix problems on the site.
Turning on the Error Log
First of all, you need access to the wp-config.php file itself. The file is located in the root directory of WordPress, and in order to edit it, we need an FTP client or File Manager if you have access to cPanel.
Open the wp-config.php file and find the line “ That’s all, stop editing! Happy blogging .”
Just before this line, add a new line of code:
define (‘ WP_DEBUG ‘, true);
This line may already be present in the file with the value FALSE. In this case, you do not need to duplicate it, just change FALSE to TRUE.
With this code, you will convert WordPress to debug mode. You need to be prepared for the fact that when you turn on the debugging mode, WordPress will start displaying all warnings and errors on the site at the top of the page, both in the admin area and on the site itself.
Therefore, the general recommendation is this: do not leave the debug mode on permanently, use it only when necessary.
Now, to additionally include the record of all detected errors and warnings in the log file, add one more line of code in the same wp-config file, just below the line with WP_DEBUG:
define (‘ WP_DEBUG_LOG ‘, true);
Viewing the log file for Error logs
Before you see any entries in the error log file, you need to provoke these errors first.
Open the necessary page, entry or section of the site where potential errors are expected, and try to perform the usual actions that any visitor to this page would have done. Anything that can lead to errors.
Now you can check what errors were added to our log file.
Re-connect to the site via FTP or File Manager and go to /wp-content/ directory.
You will see the file debug.log
Download this file or open it in the view mode directly from the FTP client. The file stores the usual textual information, for its opening, is suitable for ordinary Notepad:
That’s it! We showed a simple way how to include Error logs on the WordPress site through wp-config.php.
Incoming Search Items:
Turning on the Error Log in WordPress
wp_debug Error Log
Error log through wp-config.php
Enable Error Log in WP
Enable Error Log in WordPress