Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Set Up WordPress Error Logs in WP-Config

We find that setting up error logs is essential for your effective troubleshooting and maintenance on WordPress websites.

The wp-config.php file controls your WordPress site settings and can also be used to enable error logging. This feature helps you identify and resolve issues more efficiently.

In this article, we will demonstrate how to set up WordPress error logs using the wp-config.php file. By following these instructions, you can streamline your troubleshooting process and ensure your website runs smoothly.

How to Set Up WordPress Error Logs in WP-Config

Why Set Up WordPress Error Logs Using WP-Config?

The wp-config.php file is an important WordPress configuration file. It contains settings that tell your website how to connect to your WordPress database, the database table prefix to use, and authentication keys to make your WordPress site more secure.

Apart from default WordPress settings, the wp-config file can also be used to enable WordPress debugging mode and save WordPress error logs.

This helps you find WordPress errors by identifying the plugins or scripts that are causing them. You can then go ahead and find a fix for those WordPress errors.

That being said, let’s take a look at how to enable and set up WordPress error logs by editing the wp-config file.

Setting Up WordPress Error Logs in WP-Config File

First, you will need to edit your wp-config.php file. If you haven’t done this before, then you can see our guide on how to edit the wp-config file in WordPress.

You can access the file by connecting to your website using an FTP client or the file manager app provided by your hosting provider.

Edit Your Website's wp-config.php File

You will find the wp-config.php file in the root directory of your website.

Note: Editing WordPress core files can be dangerous and break your site if you make even a small error. That’s why we recommend that only advanced users do so.

Enabling Debugging Mode

Next, you will need to open the file in any text editor and look for the line that says ‘That’s all, stop editing! Happy blogging.’

Just before this line you need to add the following code:

define( 'WP_DEBUG', true );

It is possible that this code is already in your wp-config.php file and is set to ‘false’. In that case, you just need to change it to ‘true’.

This line will turn on WordPress debug mode. This means that WordPress errors and warnings will be displayed inside your admin area as well as on the front page of your website.

Next, you need to enable error logging so the error messages are saved in a file.

Enabling Error Logging

If you want errors to be logged, then you will also need to add the following code in your wp-config.php file just below the WP_DEBUG line.

define( 'WP_DEBUG_LOG', true );

Don’t forget to save your changes and upload your wp-config.php file back to your website.

Congratulations, you have turned on WordPress error logging. Next, we’ll take a look at how to use the log to find and fix errors when troubleshooting.

Reviewing Your WordPress Error Logs

First, you need to visit your WordPress site and access the pages that were resulting in errors or warnings. After that, you will need to connect to your website using an FTP client or file manager app in your WordPress hosting cPanel.

Once connected, go to the /wp-content/ folder. Inside it, you will find a file called debug.log.

Download, View, or Edit the debug.log File

You can download, view, or edit this file.

It will contain all WordPress errors, warnings, and notices that were logged.

Debug.log Contains Error Messages and Time Stamps

Expert Guides on Troubleshooting and Debugging WordPress Errors

Now that you know how to set up WordPress error logs, you might like to see some other guides related to logging, troubleshooting, and debugging errors in WordPress.

We hope this article helped you learn how to set up WordPress error logs in the wp-config file. You may also want to see our guide on how to create a free business email address and our expert pick of the best email marketing services for small business.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

16 CommentsLeave a Reply

  1. Jiří Vaněk

    From a security point of view, is it good to have debug mode and debug log permanently on, or is it a better practice to turn it on only when a problem occurs?

    • WPBeginner Support

      It is normally better to only have it on if you are searching for an error. :)

      Admin

      • Jiří Vaněk

        Thanks for the reply, I usually used to leave it on for longer periods of time and then I learned that it’s not a good practice, so I wanted to check with the pros. Thank you for your time and new information.

  2. mohadese esmaeeli

    Hello and respect;
    As an additional note, I would like to inform users that the error log file becomes heavy and bulky over time. It is advisable to delete it. Each time an error occurs, this file will be recreated. Visit the WordPress installation path and check the permissions of the error_log file. If the file is unnecessary, delete it. This file contains errors that have occurred on the WordPress site.

    • WPBeginner Support

      It would depend on how often the site has an error but it would be a good idea to delete the file every so often.

      Admin

  3. Eddy

    Hi, quick question, one of my client’s sites has this text file error.log generated/updated under the public_html folder, yet, WP_DEBUG is set to false in wp-config, does anyone know what’s generating the error log in that file?

    • WPBeginner Support

      That may be created by the hosting provider for any errors on that site.

      Admin

  4. hassu

    My own plugin is broken, and this method does not help, the log file is empty and stays empty whatever trick i try.

    • WPBeginner Support

      The plugin may not have anything that would be sent to the error log.

      Admin

  5. Muhammad Zeshan Akhtar

    Hi Respected Sir,
    Bundle of thanks for your kind help at each point. Hats off :)

    • WPBeginner Support

      Glad our article was able to help :)

      Admin

  6. Sean

    Thanks for the help!!

    • WPBeginner Support

      You’re welcome :)

      Admin

  7. Zippp

    Oh, Gosh
    If you are saying how to turn the logging on then why don’t you say how to add there any data?

    • Erick Racancoj

      I thought the same :)

      Here is a line of code you can use once WP_DEBUG_LOG is activated:

      error_log( ‘Hello World!’ );

      • Frank Spade

        Your test code can only work, when you use aposthrophs instead of accents! ;-)

        error_log(‘Hello World!’);

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.