RichardMiracles
RichardMiracles

Reputation: 2162

define('WP_DEBUG', true); does not show errors

I enabled the errors in my wp-config file:

define('WP_DEBUG', true);

But I have an empty white page. No errors are listed.

Upvotes: 40

Views: 123467

Answers (5)

Yogendra
Yogendra

Reputation: 2234

The below code, inserted in your wp-config.php file, will log all errors, notices, and warnings to a file called debug.log in the wp-content directory. It will also hide the errors so they do not interrupt page generation.

this code you must have to insert BEFORE / That's all, stop editing! Happy blogging. / in the wp-config.php file.

// Enable WP_DEBUG mode
define('WP_DEBUG', true);

// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);

// Disable display of errors and warnings 
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);

// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define('SCRIPT_DEBUG', true);

source: https://wordpress.org/support/article/debugging-in-wordpress/

Upvotes: 39

Pierz
Pierz

Reputation: 8168

Another thing to check is the WP_CONTENT_DIR variable as that is where the debug.log file would be put. It may be checked as suggested in this question, or using the Wordfence plugin->Tools->Diagnostics->WordPress Settings. Normally it is not explicitly set unless there's a custom configuration. Though it can can be set in wp-config.php e.g. define('WP_CONTENT_DIR', '/var/www/sites/wordpress/wp-content');

Upvotes: 4

thespacecamel
thespacecamel

Reputation: 942

Plugins or themes that are using PHP's set_exception_handler() (see the docs) can also cause errors to not be shown, because their callback might just silently ignore the error. For example, I experienced the exact same thing using NextGen Gallery, but once I deactivated it, errors appeared as normal on both the page and in the debug.log file.

Upvotes: 2

cgee
cgee

Reputation: 1897

You can write this into your .htaccess file.

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag  log_errors on
php_value error_log  /home/path/public_html/domain/PHP_errors.log

Please change the error_log directory.

Upvotes: 2

Aleksandar Jakovljevic
Aleksandar Jakovljevic

Reputation: 941

Add these two lines below the

define('WP_DEBUG', true);

error_reporting(E_ALL);
ini_set('display_errors', 1);

then delete them when you don't need them any more.

Upvotes: 16

Related Questions