How To Debug And Log Errors In WordPress Site

How To Debug And Log Errors In WordPress Site

WordPress has a debugging mechanism that lets you identify errors and fix them accordingly. It lets you log the errors using the wp-config >file. The wp-config.php file is a WordPress config file that contains important WordPress settings. These settings tell your website how to connect to your WordPress database, which database table prefix to use, and generates authentication keys to make your WordPress site more secure.

It helps to identify and fix common errors in WordPress websites. In this tutorial, you will learn how you can easily set up the debugging mechanism in the WordPress website.

Prerequisites

  • A Domain Name (example.com)
  • cPanel Credentials
  • FTP Client (Cyberduck, Filezilla)
  • Text Editor (Sublime Text, Notepad)

Step 1:

Login into your cPanel with your username and password. Locate File Manager and Click on it.

How To Debug And Log Errors In WordPress Site

Step 2:

Click on public_html on the left side menu and locate the wp-config.php. You can also use an FTP client to connect to your server and download the wp-config.php file.

How To Debug And Log Errors In WordPress Site

Step 3:

Right click on wp-config.php and click View/Edit. A pop up window will appear. Click Edit again. Download the file and edit using text editor for FTP clients.

How To Debug And Log Errors In WordPress Site

Step 4:

Search for the keyword WP_debug and modify the code

 as below:

define( 'WP_DEBUG', true );

This snippet tells WordPress to activate the debug mode.

By default, it is set as false. By setting true, now you have enabled the debugging mode of your WordPress site. When you enable the debugging mode, you will see errors and warning on the front end of your website. This is okay if you are testing your website on a staging environment.

For live sites, you can instead log your errors into your wp-config.php file. Add the following line of code after the above wp_debug line.

define( 'WP_DEBUG_LOG', true );

It is possible that this code already exists in your wp-config.php file and is set to false. In that case, you just need to change it to true.
Click Save changes on the top right corner to save your changes.
This above line alone will turn on WordPress debug mode. However the downside of using this debugging alone is that you will see WordPress errors and warnings inside your admin area as well as front page of your website. This will create a bad user experience.

Step 5:

Your WordPress logs are now ready to be viewed if needed. It is located inside the public_html directory of your WordPress site.

Go to your site and visit the pages with errors and access the /public_html/wp-content/ to find the file debug.log

How To Debug And Log Errors In WordPress Site

Download the debug.log file to view the logged issues and warnings.
The error log will not track issues that have occurred in the past. Therefore, if you’re trying to troubleshoot a specific issue, you’ll need to trigger it again by interacting with the element or performing the action that caused it. This should prompt WordPress debugger to log the error.

Conclusion:

By following these steps, you can easily track your errors and find solutions to them.

Check out these top 3 WordPress hosting services:

A2 Hosting
$1.95 /mo
Starting price
Visit A2 Hosting
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.8
  • Pricing
    4.0
IONOS
$1.00 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
HostArmada
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0

How to customize the WordPress Admin Login Page

Who wouldn't want to customize their login page? In this guide, we will learn ho
1 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How To Increase Maximum File Size Upload In WordPress

Low file size limit in wordpress can stop you from uploading some plugins, theme
1 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to Fix “Error Establishing Database Connection.” in WordPress

Error Establishing a Database Connection is one of those curses that could be ca
4 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How To Logout All Users In WordPress At Once

What will you do if your WordPress site has been hacked or want all the users to
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top