Are you seeing an error without knowing why? WordPress has a function that helps you record errors, which are error logs. WordPress’ wp-config file 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!
error log
Why and when do we have 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 whether it is more secure to create an authentication key for a WordPress site.
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 allows users to find plugins or script errors. Let’s see how we enable this function.
how to set up WordPress error log
First, the user needs to edit the wp-config.php file. You can access this file using an 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 it, stop editing! Happy blogging. ‘
Just before that line, add the following code:
define( 'WP_DEBUG', true );
Chances are that this code is already in the wp-config.php file and 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 WordPress errors and warnings in the admin area as well as in the front page of the website.
If the user wants to record the errors in a separate file, simply add the following line of code below the WP_DEBUG line.
define( 'WP_DEBUG_LOG', true );
Also don’t forget to save and upload the wp-config file to the website.
Check Your WordPress Error Log Again
First, you have to visit the WordPress site again and reach the page which is showing errors or warnings. After that, you need to connect to the website through the FTP client or the 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. All WordPress errors, warnings and notes are noted in this file.
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 liked this post, please like it and comment below!