Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Set Up WordPress Error Logs in WP-Config

Do you want to set up WordPress error logs in wp-config file? The wp-config file in WordPress not only controls your WordPress site settings, it is also a very a useful debugging tool to help you find and fix errors. In this article, we will show you how to set up WordPress error logs in the wp-config file.

Setting up WordPress error logs

Why and When You Need to Set up WordPress Error Logs in WP-Config

The wp-config.php file is a WordPress configuration 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.

To learn more about wp-config file, please see our article on how to edit wp-config file in WordPress.

Apart from default WordPress settings, wp-config file can also be used to define several other parameters. It can also 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 setup WordPress error logs in wp-config file.

Setting up WordPress Error Logs in WP-Config File

First, you will need to edit your wp-config.php file. You can access it by connecting to your website using an FTP client or File Manager app in cPanel.

Edit wp-config file

You will find wp-config.php file in the root directory of your website. 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 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.

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.

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 a FTP client or file manager app in your WordPress hosting cPanel.

Once connected, go to /wp-content/ folder and inside it your will find a file called debug.log.

Debug log

You can download, view, or edit this file. It will contain all WordPress errors, warnings, and notices that were logged.

WordPress errors logged

That’s all we hope this article helped you learn how to set up WordPress error logs in WP-Config file. You may also want to see our ultimate list of most wanted WordPress tips, tricks, and hacks for beginners.

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.

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

10 CommentsLeave a Reply

  1. 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?

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

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

    • I thought the same :)

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

      error_log( ‘Hello World!’ );

Leave a Reply to Erick Racancoj Cancel 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.