Do you want to create a WordPress error log for your website? The WP-Config file is one of the most important files in the WordPress core. It contains all of the settings for your WordPress website and is a great debugging tool. Debugging is the process of locating and resolving errors within a specific program or platform.
WordPress is an extremely popular platform but there are a lot of common WordPress errors that occur. These errors occur because of various things like server issues, plugins, themes, custom code, and other various reasons. Having an error log can significantly improve your chances of quickly resolving any errors you may run into on WordPress. Today, I will demonstrate how to create an error log in WordPress by using WP-Config.
Why Use an Error Log in WordPress
Errors can and will occur at any point while running a WordPress website. Using an error log has a lot of benefits. The error log will show you exactly what scripts are causing the error messages. This will let you know if it is a plugin or theme and which specific one it is. This is also a great way to know if it is an error on your end or on your web hosts‘s end. If you do not see a script causing the problem, there is a number of things that can go wrong on your web hosts’ end.
Cyber attacks are very popular in today’s world and new security measures are created to improve website security every day as we have recently done at GreenGeeks by introducing WordPress Protect. Among the many types of cyber attacks, DDOS attacks are the most popular. These can overload any server and cripple your website. In this situation, there is not much either you or the web host can do until it is done. It is also not uncommon for servers to stop working or have a momentary glitch. This could be because your web host is using outdated or old equipment. If this is the case you may consider switching your web host.
How to Create WordPress Error Logs in WP-Config
Today, I will demonstrate how to create an error log in WordPress by using WP-Config. No additional plugins are required to accomplish this task. You will need access to your websites cPanel, which is provided by your web host when you create an account. You should make a backup of your website before attempting this. This will ensure that if a mistake is made, you will be able to revert to the previous version of your website.
Let’s start by logging into the cPanel and clicking on the File Manager option. The File Manager will allow you to access all of the files related to your website.
You need to locate your theme’s wp-config.php file. Click on the public_html directory. Right-click on the wp-config.php file and select the Edit option.
A pop-up window will show up. This box will warn you to create a backup of your files before editing anything. This will ensure that you can revert your website back to when it was working if something goes wrong. Click on the «Edit» button. A new tab will open containing all of the code from the file.
Scroll down to the bottom of the code. Look for the comment line that says «That’s all, stop editing! Happy blogging.» and paste the following code above it:
The first line may already appear in your code, but instead of the «true» value, it will have the «false» value. You must delete it before pasting this code in. This line will turn the WordPress debug mode on, while the second will create an actual log of the errors you encounter. On top of being able to view all of the errors in your error log, you will also be able to see them as notifications in the admin area. Once you have inserted the code into the functions.php file, click on the «Save Changes» button to finish.
Congratulations, you have successfully enabled debug mode and created an error log for your WordPress website. You are probably wondering where exactly the error log is at this point. It is located in the wp-content folder. Inside of this folder, look for the debug.log file. This contains the full error log of all of the pages you have encountered an error on, while in debug mode. You will not see this file if you have not encountered any errors. It only appears when something is written inside of it.
If you wish to disable debug mode at any time, simply edit the wp-config file and change the debug mode value from «true» to «false» and you will be back to normal.
Know Exactly What is Causing the Errors in WordPress
You will encounter plenty of common WordPress errors that can cause you frustration and downtime for your website. An error log will tell you exactly what script from what plugin, theme, or other file is causing the error. This will greatly speed up your website’s recovery time. Having a backup in place will ensure you can roll back if the error is causing significant downtime.
Not only will the error log uncover what errors are your fault, but you will also be able to determine if some errors are your web host’s fault. If you are noticing regular downtime because of your web host, then it is time to switch.
Where are the errors coming from on your website? Do you like using the debug mode to uncover where the error is occurring?
Author: Chris Racicot
Chris is the Support Manager at GreenGeeks and has been with the company since 2010. He has a passion for gaming, scripting and WordPress. When he’s not enjoying his sleep, he’s working on his guitar skills and fiddling with 3d printing.