In this post, I will show you how to find the error log file in your WordPress installation. I will also show you how you can generate this log file if this is not already created for you.
So you can download & read the file, and fix the errors.
Where can you find the WordPress error logs file?
You will find the WordPress error logs file in the root directory where the wp-admin, wp-content & wp-includes folders live. The logs file is named “error_log” (without any extension).
This “error_log” is your WordPress error logs file that contains all the warnings & errors, the date & time of the error/warning occurred, the path of the file that triggered the error, etc.
From there you can easily find the affected plugin, theme, or file and fix the issue.
How can you enable/generate error logs in WordPress?
If you don’t see the “error_log” file in the root of the WordPress installation, you have to write two lines of code in the wp-config.php file. It’s very easy and you don’t have to be tech-savvy to follow along.
Also, I will show you an alternative way to generate the log file using a plugin.
Enable error logging using wp-config.php
In the root of your WordPress installation, look for a file named wp-config.php. It also lives in the same directory where the “wp-content” folder lives.
Open this config file and search for the following word: WP_DEBUG
The entire line will look like the following:
define( 'WP_DEBUG', false );
Now replace the false with true. And add another line underneath it:
define( 'WP_DEBUG_LOG', true );
Altogether, these two lines will look like as follows:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
Don’t forget to save the file. After you save it, it will allow WordPress to generate an error log file.
Please note that defining “true” to the WP Debug & Log does not create the error_log file immediately. Your site will generate this log file after experiencing any error or warning.
Enable debugging using a plugin
If you want to avoid editing wp-config.php then you can use this as an alternative.
On your WordPress website, install & activate a plugin named “WP Debugging” by Andy Fragen.
If you’re fairly new to WordPress, see how to install a plugin.
You don’t need any additional settings or configuration for this plugin. It does the same thing as you saw in the last section.
How to download the “error_log” file and read it?
I already showed you where you can find the log file. Downloading a file is nothing new but there is a caveat especially when it comes to reading.
By default, this file does not have an extension such as “.php, .js, .html, etc.” So when you try to open it, your device will ask you to select an app to read this file.
Anyways, to avoid, this hassle, save this log file in “txt” format. Altogether, the file name will be “error_log.txt” and then you can open the file using Notepad++, Sublime Text, VSCode, or any other code editors. The video below shows how to download the error logs file, how to name it, and how to enable this file generation (if this is not found).
“error_log” is a file that contains all the errors, warnings, the date/time the error occurred, and the path of the file that triggered the error.
It’s not only helpful but also walks you through the files/folders, themes, and plugins that generated errors. It gives you the opportunity & helps you to find and fix problems on your website.
This file location & name may vary depending on the hosting company you’re using. But it’s rare. In a few cases, this can be found in the “wp-content” folder, or inside the “logs” folder. Also, if you’re generating it using any plugin, the logs file can be named & found differently.