A Comprehensive Guide to WordPress Error Logs

Table of Content

Having a WordPress website serves as a boon in today’s world, no matter if you are just a blogger or a well-established business owner. It offers numerous scaling opportunities for each business niche.

Under such circumstances, it is a good idea to check how the server responds to the audience’s queries and whether the website is about to trigger any error codes or is in seamless condition.

One of the best ways to do that is to set up and read the WordPress error logs. From permissions concerns to PHP issues, there are many types of errors that can occur in WordPress – these are crucial practices to conduct but also complex for non-technical.

That’s why, in this article – we will help with a step-by-step breakdown starting from acknowledging ‘What are WordPress error logs?’, the kinds of error logs in WordPress site, and different methods of enabling WordPress debug mode.

What is WordPress Error Log?

The first thing you need to understand is that common WordPress errors, such as Internal Server Error 500, WordPress critical error, or dreaded WordPress white screen of death and error logs, are different. Where a specific error code displays the terminated version, these error logs help you get the list of error messages caused due to an issue in a missing file, plugin or theme.

By using WordPress debug mode, you can easily troubleshoot errors and prevent your site from diving into some serious error threats. Here are some different levels of error that get indicated by Apache so that you can plan the debugging errors and warnings as per the priority.

Different Error Log Levels Defined in Apache:

  • emerg: emergency – the system does not function;
  • alert: the error must be immediately corrected;
  • crit: critical – is a critical error;
  • error;
  • warn — warning;
  • notice — notification (normal operation);
  • info — information message;
  • debug — debug message.

To ensure a secure, healthy, and speedy website, you better pay precise attention to these error levels.

Best Time to Check Access & Set Up WordPress Error Logs

Prevent it before it occurs! You have two options here – If you can handle these technical terms without creating any other mess in the backend or entirely losing the web, you may enable debug mode and start troubleshooting by yourself.

On the other hand, you can choose from WordPress website maintenance service pricing & plans and let the experts handle it all for you around the year. Moreover, hiring dedicated WordPress experts is also an available option – if you want them to handle the log file for you specifically.

Monitoring these error logs can help you with web performance, analytical reports and troubleshoot the issues before the arrival. As you can get the list of all in the WordPress dashboard itself, the entire process becomes seamless. Here are the major timeline segments by which you should analyze the error logs:

  • Unable to load WordPress website or getting blank screen errors. 
  • Getting warnings like 401, 404, 504, 505, etc. 
  • Slow loading website or particular pages.
  • If the theme or plugins don’t work properly. 
  • Figure out plugin conflict issues and solve them. 
  • The website crashed.

Types of  Error Logs in WordPress Website

Usually, there are 10+ common WordPress errors that can occur due to inconsistent or imprecise practices towards the root causing the errors in the site. To get the whole range of logs and detailed information, you can locate the debug.log file from the file manager → file manager → / wp-content, folder.

This file stores all logged WordPress notices, warnings, and errors on your website for easy review and troubleshooting. Thus, with this debug log file, there are numerous forms your website will improve:

  • Analyzing and debugging errors.
  • Improved and error-free user experience.
  • Auditing access to the website.
  • Monitoring plugin performance.
  • Track user activity.

How to Enable WordPress Debug Mode?

As error logs provide valuable information about issues and help you fix problems more efficiently, finding and accessing these WordPress error logs is important.

The entire process is defined as enabling debug mode in WordPress, but before that; let’s first understand what different debugging snippets do for you:

Functioning of Debugging Mode Variables

As there are four different variables that get added to the wp-config file to enable debug mode, understanding how each of those works is important so that can enable them accordingly.

define( ‘WP_DEBUG’, true );

WP_DEBUG is a PHP constant (a permanent global variable) that enables the ‘debug‘ mode throughout the entire WordPress site. 

When you start editing this file, the code snippet must be set to ‘define( ‘WP_DEBUG’, false);’ which you’ll need to replace with the code mentioned in the ‘Editing and uploading the wp-config file‘ section below.

By enabling this – all PHP errors, notices, and warnings will be displayed. Due to its standard behavior, these error messages are shown on the main web page or on the white screen of death.

Not to worry, we will help you with code snippets that will create a bedug.log file instead of messing up the website due to such errors.

define( ‘WP_DEBUG_LOG’, true );

It helps you to collect all errors, notices, warnings, and save them in a log file named debug.log. By using this, reviewing and fixing errors gets way easier and also gives you a free hand to correct them later.

define( ‘WP_DEBUG_DISPLAY’, false );

It allows you to control whether you want to show the debug messages on the particular HTML pages or not. We suggest setting this to false only, as enabling this to true will affect the page crawling and SEO rankings.

define( ‘SCRIPT_DEBUG’, true );

SCRIPT_DEBUG is an associated constant that compels WordPress to utilize the ‘dev’ version of core CSS and JavaScript files instead of the compressed files. This proves advantageous when evaluating alterations to any pre-existing .js or .css files.

Enable WordPress Debug Mode via SFTP/FTP

If you’ve accomplished such technical approaches before, you must be familiar with the FTP (File Transfer Protocol). SFTP/FTP is just a secured version of it, which stands for Secure File Transfer Protocol and adds a safeguarded layer to the file transferring process. Here you go with the steps:

Connect to the Website via SFTP/FTP

  • If your SFTP/FTP access has yet to be requested, you’ll need to enable it first.
  • Navigate to My Site(s) → Settings → Hosting Configuration.
  • Click on the Enable SFTP/FTP button.
  • You’ll receive details, including host, username, password, and port.
  • Connect with SFTP/FTP software such as FileZilla using the same credentials.

Navigate and Download the wp-config File

  • From the root folder of hosting only, you’ll get the wp-config.php file. Alongside folders such as wp-content, wp-admin, and wp-includes.
  • Download the wp-config.php; here are the best IDEs for PHP development you can use to edit it. Also, download a copy of the same file so that an unintentional snippet code error occurs; you can use this copy file as a backup.
wpconfigfile-in-sftp

Editing and Uploading the wp-config File

  • Enter the code snippet mentioned below, BEFORE /* That’s all, stop editing! Happy blogging. */:
  • Save the file and go to the web-connected SFTP/FTP server.
  • Delete the currently uploaded wp-config file first, then upload the edited file on which we mentioned the above code.
  • You are done there!

Access to WordPress Error Logs

  • Navigate to the wp-content folder. If there is any error on your Website, you’ll find a new file named debug.log – in which every error and alert will be mentioned.
  • You can download that file on your computer, check out the mentioned issues, and figure them out simultaneously.

Enable WordPress Debug Mode via Web Hosting

  • Go to Cpanel → File Manager.
  • In the root website folder → wp-config.php file.
  • Right-click on the wp-config.php file and tap on edit.
  • Enter the code snippet mentioned below, BEFORE /* That’s all, stop editing! Happy blogging. */:
// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );

// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define( 'SCRIPT_DEBUG', true );
  • This will turn on WordPress debug mode.
  • You can access your WordPress error logs with the file named debug.log in the wp-content folder.

Enable Debug Mode Using WP Debugging Plugin

Enabling error logging using a plugin is the best for both technical and non-technical, as you don’t redirect to any WordPress hosting panel to check on the errors.

Moreover, its reports also get updated whenever an error occurs or is about to trigger any error. Some of the popular WP debugging plugins are Akismet Anti-Spam, Health Check & Troubleshooting, and WP Debugging.

Akismet Anti Spam Plugin Setup :

  • Navigate to WP Admin Panel → Plugins.
  • Tap on Add New → Type Akismet Anti Spam.
  • Click on Activate.
  • To complete the setup process, it will ask for an API.
  • By keeping the window open, Visit Akismet’s official Website.
  • Tap on ‘Get Started With Akismet’, and pick the best fitting plan for you.
  • Once you are done with that, fill out the required information. Afterwards, you’ll receive an email for verification purposes – once you are done with that, you’ll get access to your Akismet dashboard and API key, too.
  • Copy the API key, come back to the WordPress dashboard, and navigate yourself to the plugins Akismet setup.
  • Under Akistment, tap on Setting. It will respond with a setup process pop-up.
  • Paste the API key, tap on connect with the API key and the Save Changes in the last step

Health Check & Troubleshooting Plugin Setup:

  • Navigate to WP Admin Panel → Plugins.
  • Tap on Add New → Health Check & Troubleshooting (By The WordPress.org community).
  • Install and click on Activate.
  • Go to the Plugins page. Under the Health Check & Troubleshooting plugin, you’ll see a ‘troubleshoot’ option.
  • To enable this debug mode, go to Tools → Site Health → Troubleshooting and click on Enable Troubleshooting Mode.
  • After troubleshooting has been enabled, you’ll be redirected to a panel from where you can fix errors on your site by enabling one plugin at a time or by switching to a different theme.

WP_Debug Plugin Setup:

If configuring WordPress error logs in the wp-config file is too complex for you; you can do the same by using the plugin and avoid editing any core files from the control panel. Here you go with the steps:

  • Navigate to WP Admin Panel →  Plugins.
  • Tap on Add New → WP Debugging.
  • Install and click on Activate.
  • Navigate to the Dashboard → Tools →  WP Debugging.
  • Tick the check box next to the “Set WP_DEBUG to true” option
  • Once you are done, click the “Save Changes” button.

Disable Debugging (Optional):

After troubleshooting and resolving the issues, it’s a good practice to disable debugging to prevent the log file from growing indefinitely. To do this, simply remove or comment out the code snippet you added to the wp-config.php file:

// Disable debugging (remove or comment out these lines)
// define( 'WP_DEBUG', true );
// define( 'WP_DEBUG_LOG', true );
// define( 'WP_DEBUG_DISPLAY', false );
// @ini_set( 'display_errors', 0 );
// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
// define( 'SCRIPT_DEBUG', true );

FAQs About Finding and Accessing WordPress Error Log File

How do you check the PHP error log in WordPress?
  • Server's root folder → error. log.
  • In public_html or similar folder → error. log.
Additionally, if you have debugging enabled in WordPress and saved it to a file, it will be in the wp-content folder → debug. log.
Does WordPress have a log file?
Yes, WordPress does have a log file. You can navigate to your /wp-content/ debug.log file in your File Manager.
What is your approach to troubleshooting and debugging WordPress errors?
Enabling WordPress debug mode is the best approach to troubleshooting and debugging WordPress errors.

Conclusion

WordPress log of errors can be a real lifesaver and can quickly help you understand why something has gone wrong on your website. 

They can initially seem a little intimidating but once you get used to accessing and reading them you’ll come to understand the value of the information they offer. If you find any complexity in accessing your error log in WordPress or debugging them – you can consult with our experts.

author
Mehul Patel is a seasoned IT Engineer with expertise as a WordPress Developer. With a strong background in Core PHP and WordPress, he has excelled in website development, theme customization, and plugin development.

Leave a comment