Cara menggunakan wordpress debug.log not created

This week I was upgrading a WordPress site. It had a partial blank page in the admin. It wasn’t a full White Screen of Death, but there was clearly a bug that needed fixing.

This tutorial will help you to debug issues like this. I’m going to show you how to use WordPress’ debugger to find the cause of this issue.


Example Issue

Cara menggunakan wordpress debug.log not created

As you can see in the example screenshot, nothing appears in the main content area. None of the admin pages work for me.

Without a detailed error message, I’m left guessing what the issue might be. Getting a detailed error message is the key to quickly resolving the issue.

In order to get a detailed error message, I’ll need to enable the wp-debug in the wp-config.php file.


Step #1. Edit your wp-config.php file

Cara menggunakan wordpress debug.log not created

If you’re not familiar with the wp-config.php file, please check out our Guided Tour of it.

Use your host’s file manager and navigate to your WordPress root. Edit your wp-config.php file and look for the following line of code:
define(‘WP_DEBUG’, false);

Change that line of code to:
define(‘WP_DEBUG’, true);
define(‘WP_DEBUG_LOG’, true);
define(‘WP_DEBUG_DISPLAY’, false);
@ini_set(‘display_errors’,0);

Afterward, save your file.

The above code will tell WordPress to start logging errors. It will output the errors to the wp-content/debug.log file.


Step #2. Examine your debug.log file

Cara menggunakan wordpress debug.log not created

In the file manager, navigate to your wp-content folder. Within there, look for and edit the debug.log file.

At the bottom of your file, you should see your error message. Double check the date to make sure it’s the right one.

With this detailed error message, you should now be able to resolve the issue. It should tell you exactly what the issue is. From here, based on the error message, you’ll:

  • be able to Google for a solution
  • ask for help in our support forum or another forum
  • know exactly how to fix the issue yourself

It might require updating (or disabling) a plugin, theme, or PHP version. The detailed error message will be the key to figuring out what’s needed.


Step #3. Turn Off Debugging

Cara menggunakan wordpress debug.log not created

Once you’re done, go back to your wp-config.php file and change:
define(‘WP_DEBUG’, true);
define(‘WP_DEBUG_LOG’, true);
define(‘WP_DEBUG_DISPLAY’, false);
@ini_set(‘display_errors’,0);

back to:
define(‘WP_DEBUG’, false);

and save your file. That will change things back to normal.


Pro tip: White Screen of Death

The White Screen of Death (WSoD) is where the page is completely blank, not just partially. Sometimes the above steps won’t work and you’ll need additional debugging. If you’re in that situation, give our White Screen of Death tutorial a try.

If you have just updated a plugin and you’re seeing errors, try rolling back to a previous version.

Instructor

  • Nick Savov

    Nick is the Director of Support at OSTraining and you can find him in almost every area of the site, from answering support requests and account questions to creating tutorials and software.

    WordPress comes with a debugging system that can log any error messages displayed on your site. This can help you discover and fix problems on your website.

    In this article, we’ll show you how to find and access your WordPress error logs.

    Cara menggunakan wordpress debug.log not created

    How and When Can WordPress Error Logs Help?

    Are you having problems with your WordPress website? Checking your WordPress error logs can help you find the source of problems such as slow website performance, plugins that aren’t working properly, and website crashes.

    What is an Error Log?

    An error log is a list of error messages generated by your website and the dates and times they occurred. Once WordPress debug mode is turned on, these messages are collected in a file, so that you can review them later.

    Your WordPress error log is a troubleshooting tool that can help you identify the plugins, themes, or code that are causing problems. You can then go ahead and find a fix for those WordPress errors.

    For example, checking the error logs can help troubleshoot errors like the WordPress white screen of death, PHP errors, the invalid JSON error, and the “Sorry, you are not allowed to access this page” error.

    That being said, let’s have a look at how to find and access your WordPress error logs. The first step is to enable WordPress debug mode, which you can do using either a plugin or code.

    Enabling WordPress Debug Mode With a Plugin

    WordPress debugging is turned off by default, so WordPress will not be logging any errors. If you can still log into your WordPress site, then you can enable debug mode using a plugin.

    The first thing you need to do is install the WP Debugging plugin. For more details, see our step by step guide on how to install a WordPress plugin.

    Cara menggunakan wordpress debug.log not created

    Upon activation, the plugin automatically activates WordPress debug mode, and error messages on your site will now be logged.

    Enabling WordPress Debug Mode Using Code

    You can also turn on WordPress debug mode using code. This is suitable for more advanced users, or if you can’t log in to your WordPress admin area.

    You will need to edit your wp-config.php file using an FTP client or the file manager option in your WordPress hosting control panel.

    Cara menggunakan wordpress debug.log not created

    Once you have the file open, you need to find the text where it says ‘That’s all, stop editing! Happy blogging.’

    Just before this line, go ahead and add the following code:

    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    

    For step by step instructions, see our guide on how to set up WordPress error logs in wp-config with code.

    How to Find and Access WordPress Error Logs

    Now that you have enabled WordPress debug mode, any future error messages on your website will be stored in the WordPress error logs.

    That means that your logs will be empty at first. You will need to try to recreate the problem on your site, so the error messages can be saved to the log file. For example, you should revisit any posts or pages that are causing an error.

    Next, you need to connect to your website using an FTP client or the file manager option in your WordPress hosting control panel. If you haven’t used FTP before, then you may want to see our guide on how to use FTP to upload files to WordPress.

    Once connected, you should navigate to the /wp-content/ folder. Inside the folder, you will find a file called debug.log. This file contains every WordPress error message, warning, and notice that has been logged.

    Cara menggunakan wordpress debug.log not created

    To see the contents of this file you will need to download, view, or edit it. You can then inspect the error messages along with the date and time they occurred. This information can help you find a solution to the problems you are encountering on your website.

    Cara menggunakan wordpress debug.log not created

    How to Fix Issues Found in WordPress Error Logs

    Once you’ve accessed your WordPress error logs, you can find the error message that was logged at the time the problem on your website occurred. Keep in mind that the times displayed are UTC, not your own local time.

    While most users won’t understand what the error messages mean, they’re a good place to start troubleshooting. Once you note the error message and code, you may find a solution to your problem in our guide on the 50 most common WordPress errors and how to fix them.

    If you can’t find the solution on your own, then you can reach out for help on our free WPBeginner Engage Facebook Group where you can get help from our WordPress experts and over 80,000 users. Make sure you quote the error code or message you found in the WordPress error logs.

    Other places you can turn for help are the official WordPress forums, your WordPress web hosting company’s support team, or the designated support area for the plugin or theme you are having trouble with.

    When asking for support, check our guide on how to properly ask for WordPress support and get it to learn the right way to ask questions and the best places to find support.

    Disabling WordPress Debug Mode

    Once you have fixed the issue on your WordPress site, we recommend you disable debug mode.  Leaving it on may slow down your website and can potentially leak unwanted information which is a security risk.

    If you enabled debug mode with a plugin, then simply navigate to Plugins » Installed Plugins and deactivate the WP Debugging plugin.

    Cara menggunakan wordpress debug.log not created

    If you enabled debug mode with code, then simply edit the wp-config file as you did before.

    You need to change the WP_DEBUG and WP_DEBUG_LOG lines to ‘false’.

    Cara menggunakan wordpress debug.log not created

    We hope this tutorial helped you learn how to find and access your WordPress error logs. You may also want to learn how to get a free SSL certificate for your website, or check out our tips on how to speed up WordPress performance.

    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.