Cara menggunakan enable error log wordpress

In this article, we will review how to access WordPress error logs for your website to assist in debugging a problem. There are a few locations that logs can be found – all need to be accessed through an SFTP connection.

Table of Contents

  • WP_DEBUG_LOG
  • WooCommerce wc-logs
  • Debugging WordPress – Video Tutorial
  • What Does Debugging Mean?
  • 7 Tips for Debugging Problems in WordPress
  • 1. Activate WP_DEBUG
  • 2. Enable WPDP Error Reporting
  • 3. Check Your Website’s Error Logs
  • 4. Use WordPress Staging Environment when Tweaking Your Code
  • 5. Enable SCRIPT_DEBUG
  • 6. Detect PHP Errors
  • 7. Take Advantage of Some Debugging Tools
  • How do I get rid of WordPress error log?
  • How do I change the error log in WordPress?
  • How do I view WordPress error logs?
  • Where is WordPress php error log?

php-errors

This error log file is automatically generated and can be accessed via SFTP. It is located above the site root, in a folder called /tmp. You will need to connect to the server via SFTP and then move up one directory (outside of the /htdocs directory) to find the /tmp folder.

Cara menggunakan enable error log wordpress

WP_DEBUG_LOG

You can enable a WordPress debug log through the wp-config.php file found via SFTP in your site root. You will need to edit wp-config.php and look for a line that reads:

define( 'WP_DEBUG', false );

Replace it with these three lines:

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

Your debug.log file will then be generated within the /wp-content directory.

WooCommerce wc-logs

If your site includes a WooCommerce store, WooCommerce also generates its own logs within /wp-content/uploads/wc-logs. Those can be accessed through SFTP.

Aug 24, 2022

Luqmanul M.

5min Read

There probably is no such thing as perfect code, and it is every webmaster nightmare whenever bugs occur on their sites or plugins. So today, we’re going to show you tips on how to debug WordPress, helping you to figure out things that may go out of your control.

  • Debugging WordPress – Video Tutorial
  • What Does Debugging Mean?
  • 7 Tips for Debugging Problems in WordPress
    • 1. Activate WP_DEBUG
    • 2. Enable WPDP Error Reporting
    • 3. Check Your Website’s Error Logs
    • 4. Use WordPress Staging Environment when Tweaking Your Code
    • 5. Enable SCRIPT_DEBUG
    • 6. Detect PHP Errors
    • 7. Take Advantage of Some Debugging Tools

Debugging WordPress – Video Tutorial

Don’t want to read? Learn how to check your WordPress error log to identify issues on your site in our video tutorial.

Subscribe For more educational videos! Hostinger Academy

What Does Debugging Mean?

Debugging, or simply debug, means to identify and remove bugs or errors in your code. The final step of debugging is to test the code correction and make sure that the problem doesn’t happen again.

This is mainly performed by web developers using debugging tools, and it’s a part of a routine in the software development stage.

The debugging process can be done using strategies such as unit test, code review, and pair programming.

So before the code or software is published to the users, developers will try to find any issues, then isolate and fix it.

Sometimes, fixing the code can be a real headache, as it might take longer than writing the code itself.

7 Tips for Debugging Problems in WordPress

When your WordPress site crashes or has the white screen of death (WSoD), the common response is to deactivate plugins/themes and check for their updates.

While that is helpful for narrowing down the culprit, it can be time-consuming, inefficient, and you could also let the real issue slide unnoticed. That’s why having the right tools can be a real game-changer.

1. Activate WP_DEBUG

Activating WP-DEBUG is probably the most simple way to log problems on a WordPress site. But unfortunately, some developers don’t do this, most likely because they forget this feature exists.

WP_DEBUG is a constant that triggers the “debug” mode in WordPress, and you can find it in the wp-config.php file. Its log can record all the activities on your site and help troubleshoot problems such as critical error on WordPress.

2. Enable WPDP Error Reporting

To detect any database connection errors, you can enable WPDP error reporting.

The global $wpdb object has a variable called $show_errors. And if you set this to true, you can make WordPress to output the SQL errors to the screen for any given query.

To enable this, go to your /public_html/wp-includes/wp-db.php and open the file. Search for the wpdb class and change the $show_errors variable to true.

3. Check Your Website’s Error Logs

Sometimes, you can encounter the interval server errors page when browsing your site. And to fix such an issue, you can review your website error logs.

Doing a general log check-up can help both beginners and advanced developers to detect the website’s problem.

You can then use Google search to look for a possible fix. We’ve covered more detailed steps to check website error log in this tutorial.

4. Use WordPress Staging Environment when Tweaking Your Code

If you want to minimize bugs on your WordPress site, you can do so by implementing the code first on a staging site.

A staging site is almost an exact clone of your live website and can be hosted on your private subdomain. This site acts as a development ground for whatever codes you want to push for your live site.

This environment is mostly not visible to visitors and search engines. So you can have more freedom to tweak, tune, and test the changes you want to bring, without affecting your public, live site.

5. Enable SCRIPT_DEBUG

By default, WordPress uses the minified version of CSS and JavaScript files to help improve your site’s load time. However, this can be a problem because it may hide errors in the scripts/plugins that you use.

To change the script execution, WordPress also provides a constant that we can add to the wp-config.php file, that is:

define( 'SCRIPT_DEBUG', true );

When the value defined as true, WordPress will automatically load the non-minified versions of all CSS and JavaScript files, making all plugins use their full version.

6. Detect PHP Errors

You can detect the PHP errors early in your scripts using phpinfo. This file can output information about the current state of PHP, including the compilation options and extensions, PHP version, PHP file size limits, maximum execution time, environment, OS version, HTTP headers, and license.

To do so, you can configure the php.ini file to enable error reporting. However, some hosting services, including Hostinger’s shared hosting plan, disable this option.

That’s because you don’t have the root access to enable the feature.

But, you can use PHP code checker to help with syntax errors instead, which provides you with a straightforward assistant to review botches in your code. And for a more thorough review, you can also use IDEs like Eclipse or PHPStorm.

7. Take Advantage of Some Debugging Tools

If you need simplicity to monitoring bug on your WordPress site, you can also take advantage of WordPress debugging plugins.

1. Query Monitor

This plugin provides a developer tool panel on WordPress. You can enable database queries, PHP errors, HTTP API calls, hooks & actions, stop editor blocks, enqueued scripts & stylesheets, and more.

Alternatively, you can also use Debug Bar and Simply Show Hooks to help you debug WordPress site. However, these two plugins may have compatibility issues with the most recent version of WordPress.

2. New Relic

You can also perform a more robust debug using a premium tool such as New Relic. This app will help you to monitor the user experience, map your WordPress architecture, find broken permalinks, analyze and improve the site’s performance, and detect anomalies before they happen.

All of those features will help you to gather data for troubleshooting so you can provide the best possible visitors’ experience. You can trial New Relic for 14-day free.

Conclusion

That’s all the tips you need to know about debugging WordPress site. As a developer, you need to identify and fix the problems before pushing whatever code/plugins to users. As a webmaster, you can also use debugging tools to identify what causes performance issues on your website.

To debug your WordPress site, you can do the following:

  • Activate WP_DEBUG
  • Enable WPDP Error Reporting
  • Check Your Website’s Error Logs
  • Use WordPress Staging Environment when Tweaking Your Code
  • Enable SCRIPT_DEBUG
  • Detect PHP Errors
  • Use Debugging Tools such as Query Monitor or New Relic

Good luck for debugging your WordPress site, we hope that you can mitigate problems to ensure a seamless visitor’s experience.

Luqman is a self-proclaimed social scientist. He is passionate about education, technology, and everything in between. He wants to help create a high-quality education system. Having spent the past four years as a social researcher and blog guru, he lends his skills to Hostinger's digital content team. As for free time, he enjoys reading scientific (and not-so-scientific) literature with a cup of black arabica coffee as a companion.

How do I get rid of WordPress error log?

No errors = no big log file. If that's not an option, you can temporarily disable errors in your log by setting "display_errors" to 0 in your php. ini. If that doesn't work, another option is to set "error_reporting" to 0 .

How do I change the error log in WordPress?

How to enable error logging.

Connect to your website via sFTP. You'll need to start by enabling sFTP on your site. Go to My Site(s) → Settings → Hosting Configuration and click the Enable SFTP button. ... .

Find and download your wp-config. php file. Navigate to your wp-config. ... .

Edit the wp-config. php file. Edit your wp-config..

How do I view WordPress error logs?

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. This file will contain all WordPress errors, warnings, and notices that were logged.

Where is WordPress php error log?

php-errors This error log file is automatically generated and can be accessed via SFTP. It is located above the site root, in a folder called /tmp. You will need to connect to the server via SFTP and then move up one directory (outside of the /htdocs directory) to find the /tmp folder.