Are you seeing an error without knowing why? In WordPress, there is a function that helps you to record errors, which are Error Log. The wp-config file of WordPress not only controls the settings in the WordPress site, but it is also an extremely useful debugging tool to help users find and fix errors. In this article, Hawks will guide how to set up WordPress error logs, let’s see!
Why and when we need to install WordPress Error Logs in WP-Config file
The wp-config.php file is a WordPress configuration file that contains important WordPress settings. These settings will inform the website how to connect to the Database such as which prefix database tables to use or the authentication key creation for the WordPress site to be more secure.
In addition to the default WordPress settings, the wp-config file can also be used to set other parameters. For example, enabling debug mode and saving WordPress error logs, this allows users to find errors of plugins or scripts. Let’s look at how we enable this function.
How to set up WordPress Error Logs
First, the user needs to edit the wp-config.php file. You can access this file using the FTP client or through the File Manager app in cPanel.
You will find the wp-config.php file in the root directory of the website. Open the file with a text editor and find the line that says’ That’s all, stop editing! Happy blogging. ‘
Just before that line, add the following code:
define( 'WP_DEBUG', true );
Chances are this code is already in the wp-config.php file and is set to false. In that case, you just need to switch to true.
This code will trigger the debug mode of WordPress. However, the downside of using debug mode is that you will see errors and warnings of WordPress in the admin area as well as the front page of the website.
If the user wants to record errors in a separate file, just add the following line of code below the WP_DEBUG line.
define( 'WP_DEBUG_LOG', true );
Also do not forget to save and upload the wp-config file to the website.
Check your WordPress Error Log again
First, you need to revisit the WordPress site and access the page that is showing errors or warnings. After that, you need to connect to the website via an FTP client or manager app in cPanel WordPress hosting.
After successful connection, go to / wp-content / and the user will see the debug.log file.
Users can download, view or edit this file. This file contains all the errors, warnings and notes of WordPress are noted.
This article shows you how to use and enable the error log function in WordPress. In the next article, Hawks will mention the tips and tricks that every WordPress user should know. If you like this post, please like and leave a comment below!