How to Enable WordPress Error Logging

How to Enable WordPress Error Logging

When managing a WordPress website, you might come across some common WordPress errors. They can cause a range of issues and even lead to a fatal error if not fixed. One way to let you know exactly which errors have occurred is by turning on the WordPress error or debug log.

The process doesn’t require you to hire WordPress experts or be skilled in web development. As long as you’re tech-savvy, it can be done in just a few minutes. Keep reading as this article will further discuss why you need to enable WordPress error logs and how to do so.

Why Enable WordPress Error Logs?

The WordPress debug mode, or WordPress error log, tracks and documents glitches, saving them on the debug.log or error_log file. This will help you troubleshoot errors and come up with solutions to fix them.

By default, the WordPress error log function is disabled. Meaning, you won’t see any warnings and error messages, or find recordings of problems your WordPress website experienced.

Whether it’s your plugins or themes not working properly, an internal server error, or PHP errors, WordPress might only display the “The site is experiencing technical difficulties” message.

That message doesn’t explain what’s causing the trouble and it may take some time to fix it via trial and error. This can result in downtime and cause you to lose traffic and profit.

Hence, it’s important that you are informed about the errors your WordPress site is facing.

Before we proceed with the tutorial, make sure to backup your website. You will only be making minor changes to one of the core files of your WordPress site. However, if something happens and the website breaks, the backup files will make it easier and quicker to restore it.

Enabling WordPress Error Logs via the wp-config.php File

For this method, you will need to download and install an FTP client like FileZilla on your computer. It requires you to edit your wp-config.php file so make sure Filezilla is configured with the correct FTP credentials before continuing with the tutorial below:

  1. Open FileZilla and access the root directory or public_html folder of your WordPress site.
  2. Find the wp-config.php file, right-click and select View/Edit to open the text editor.
wp-config.php file, highlighting the View/Edit option
  1. Scroll down to the line:
/* That’s all, stop editing! Happy publishing. */

Above it, insert the following code:

define (‘WP_DEBUG’, true);

If the line of code is already in the wp-config.php file, simply change “false” to “true”.

Line of code in the wp-config.php file
  1. Then, add the line:
define (‘WP_DEBUG_LOG’, true);
wp-config.php file
  1. Open the File menu, and click Save.
  2. Select OK if FileZilla wants to overwrite the old version of the wp-config.php file with the new one.

Refresh the page once you’ve enabled the WordPress error logs. This is to trigger the error again so it’ll be recorded on the newly enabled debug log.

Do take note that the error message will not only be visible in the WordPress admin dashboard but also on your website’s homepage. Feel free to add the following line of code as well in the wp-config.php file:

define (‘WP_DEBUG_DISPLAY’, false);

The snippet tells WordPress to hide the messages so you can review the errors later.

Enabling WordPress Error Logs via hPanel

For Hostinger users, the easiest way to enable error logging is through the hPanel. There are two ways – through PHP configurations and by editing the .htaccess file. These methods are also implementable on other non-WordPress PHP-based websites.

Via PHP Configurations

  1. Access your hPanel, navigate to the Advanced section, and select PHP Configuration.
PHP Configuration on the hPanel
  1. Click on the PHP Options tab, then tick the log_errors box.
PHP configuration, highlighting the log_errors options
  1. Leave the display_errors box empty if you don’t want users to see error messages when they visit your site.
  2. Scroll down, and press Save.

Accessing the PHP error log to check the errors occurring on your website is now possible. Keep in mind that you’ll only see the errors that occurred after you enabled error logging. Previous errors will not be added to the log.

By Editing the .htaccess File

  1. From the hPanel dashboard, go to the Files section, then click on File Manager.
hPanel's file manager
  1. Select the public_html folder, then click on the New File button located on the top-bar menu.
public_html folder, highlighting the New File button located on the top-bar menu
  1. Name the new file error_log.txt, then click Create.
Creating a log error file
  1. Right-click on the .htaccess file, and select Edit.
.htaccess file, highlighting the Edit button
  1. Add the following code:
    php_flag log_errors on
    php_value error_reporting 32767
    php_value error_log “error_log.txt”
Error log code in the .htaccess file
  1. Select the SAVE & CLOSE button. That’s it – you’ve enabled WordPress error logs.

Where to Locate Your Error Log File?

After turning the debugging mode on, you may want to know where the log file is located. If you turned on WordPress debugging using an FTP client, follow the steps below:

  1. Open FileZilla and access your website’s public_html folder.
  2. Find and select the wp-content folder, then double click the debug.log file.
debug.log file located in the wp-content folder

You’ll find a list of WordPress errors and issues that have been recorded since enabling the error logs, like so:

List of WordPress errors and issues recorded in the error log

For those using hPanel, either through PHP configurations or the .htaccess file, you can find the WordPress error log in just a few clicks:

  1. Open your hPanel, navigate to Files, and select File Manager.
  2. Click on the public_html folder and you’ll find the error_log file.
error_log file located in the public_html folder
  1. Double click to see the WordPress error logs.
Content of the error log file

If you enable debugging for a subdomain, keep in mind that the error log is in the subdirectory instead. For example, its path would be:



The WordPress error log, also known as the WordPress debug mode, is a great function for when your site is not working properly and you’re not sure why. It will help identify and record the source of the errors so you can fix them.

In this tutorial, you’ve learned how to turn on debug mode in a few different ways:

  • FTP client/Filezilla – by editing the wp-config.php file.
  • hPanel – through PHP configurations or editing the .htaccess file.

Once you have the debug mode on, the debug.log or error_log file can be found in your WordPress directory or public_html folder. However, keep in mind that the WordPress error logs will not show past problems the site faced.

Though it’s a simple process, remember to make a backup of your WordPress website files before you decide to enable error logs on the site.

If you still have questions about this topic, feel free to leave them in the comment section below.

The author

Domantas G.

Domantas leads the content and SEO teams forward with fresh ideas and out of the box approaches. Armed with extensive SEO and marketing knowledge, he aims to spread the word of Hostinger to every corner of the world. During his free time, Domantas likes to hone his web development skills and travel to exotic places.