How to Set Up WordPress Error Logs In Your WP-Config File

Download Now: Free WordPress Website Guide + Checklist
Anna Fitzgerald
Anna Fitzgerald

Updated:

Published:

From permissions problems to PHP issues, there are many types of errors that can occur in WordPress. These can be difficult to diagnose on your site, particularly if you don’t have a technical background.

WordPress user setting up error logs in WP-config

To simplify the process for monitoring and diagnosing these errors, you can set up WordPress error logs in your wp-config file. The wp-config.php file is a core WordPress file that contains your website’s base configuration details. This information allows WordPress to connect to your database, generate authentication keys that keep your site secure, and more.

By adding a few lines of code, you turn your wp-config.php file into a debugging tool that automatically finds and logs errors on your site. In the error logs, you can identify the plugin, script, or code that is causing errors. You can then troubleshoot these issues yourself or reach out to WordPress support.

Monitoring your site in this way can help you identify and resolve issues before they disrupt your data transfer capacity, negatively impact the visitor experience, or cause downtime.

To help you keep your site running smoothly, let’s walk through the process of setting up error logs in your wp-config file.

Streamline Your WordPress Site Launch with Our Free Guide + Checklist

How to Set up WordPress Error Logs in WP-Config File

To set up WordPress error logs in your wp-config.php file, you just need to add a few lines of code to the file.

It’s a simple process, but as a best practice, you should always make a copy of your wp-config.php file before editing. That’s because even a small error in the file can make your site inaccessible.

Here's a quick video you can watch to follow along with the steps below.

To start, log in to your control panel and open the File Manager. Locate the wp-config.php file and right-click to copy it. Rename the file wp-config.php.backup.

Now that you have a backup, right-click the original wp-config.php file. Click the Edit option.

Right-click the wp-config.php file and click the Edit option

Source

Scroll down to the end of the file to the line that reads /* That's all, stop editing! Happy blogging. */

Right before this line, you might see the following line of code: define(‘WP_DEBUG’, false);

If you do, delete it then copy and paste the following lines of code:

 

 

   define( 'WP_DEBUG', true );

define( 'WP_DEBUG_LOG', true );

define( 'WP_DEBUG_DISPLAY', false );

@ini_set( 'display_errors', 0 );

Save your changes. Your site’s “debug mode” will now be turned on and all errors will be saved to a debug.log log file inside your /wp-content/ directory.

Errors and warnings will also be hidden on the front end of your site. By hiding these error and warning messages from your visitors, you’ll help ensure they have a seamless experience on your site.

Reviewing Your WordPress Error Logs

To review your error logs, navigate to your /wp-content/ folder in your File Manager. Locate the debug.log file.

Managed WordPress-Copy my wp-content folder

Source

This file will contain all WordPress errors, warnings, and notices that were logged. Note that you will only see this file if your site has encountered any errors.

The debug.log file will contain all WordPress errors, warnings, and notices that were logged

Source

At this point, you can attempt to fix the problem(s) on your own since the WordPress log can help you understand what’s causing the error by naming the element at fault. You can also reach out to WordPress support for help. Make sure to share the text from the error log, which will help the support rep understand the problem and provide you with a solution.

You’re all done now! With error logging automated on your site, you’ll be able to keep track of errors that occur on your site more easily. This monitoring can help you quickly resolve any issues before they damage your site’s reputation or your visitors’ experience.

wp

 

Related Articles

We're committed to your privacy. HubSpot uses the information you provide to us to contact you about our relevant content, products, and services. You may unsubscribe from these communications at any time. For more information, check out our Privacy Policy.

Launch your WordPress website with the help of this free guide and checklist.

CMS Hub is flexible for marketers, powerful for developers, and gives customers a personalized, secure experience

START FREE OR GET A DEMO