33

Installing drupal 8 core (using standard profile). whenever I get exception/error, I get blank page with "The website has encountered an error. Please try again later." (as below image) text and no details/trace about error.

enter image description here

47

On a development site I would suggest uncommenting the following lines in the settings.php file. emacs sites/default/settings.php

if (file_exists(__DIR__ . '/settings.local.php')) {
  include __DIR__ . '/settings.local.php';
}

and then copying the file example.settings.local.php from /sites folder to /sites/default folder and rename it to settings.local.php

cp sites/example.settings.local.php sites/default/settings.local.php

In addition to adding the following setting

$config['system.logging']['error_level'] = 'verbose';

it also adds a few other settings which will help you in debugging and making development easier. If you don't want any of them in particular, you can always comment them out.

Note : If you think adding a file_exists call to each page will slow down the site, you can always remove it in the production code.

  • If you don't have an example file, you can also just create a file containing <?php $config[...; – Danielle Madeley Feb 20 '16 at 0:24
  • 1
    As mentioned below the Devel module can make things easier for Drupal 8. Verified that the $config['system.logging']['error_level'] = 'verbose'; settings appears to work. – Darrell Ulm May 2 '17 at 16:41
  • I have created a docker container that comes with the necessary settings for debugging and non-caching - hope it's useful: hub.docker.com/r/feikede/drupal-dev – Rainer Feike Sep 17 '18 at 11:00
17

Add the following line in the settings.php file.

$config['system.logging']['error_level'] = 'verbose';

See Make developer tricks / tools for D8 more discoverable/obvious for more details.

6

Here is the variable with the different values :

$config['system.logging']['error_level'] = 'all'; // hide|some|all|verbose
  • 2
    Thanks for adding the possible values. – plocks Mar 18 at 13:10
  • Yes, thanks for adding the possible values, which were surprisingly difficult to find. – arnoldbird May 7 at 14:09
5

An easy option, if you have access to Drupal Console, is to enable the development/debugging environment using drupal site:mode dev; when you are ready to change it back to production, use drupal site:mode prod.

  • Nice trick with the Drupal Console – ognockocaten Mar 2 '17 at 20:43
3

To get basic error messages in Drupal 8 you don't need to touch any code at all. Just go to:

/admin/config/development/logging

and set "Error Messages to Display" to an appropriate level.

You can also view your recent errors through the admin interface:

/admin/reports/dblog

That said, other answers about settings files are relevant – you should only ever make errors visible on your development site, not production.

Overwritten $config objects/keys in settings.php won't be written to the sync directory when exporting, so providing your settings.php is in .gitignore, you can continue to safely use the configuration system to sync between clones of the same site.

0

You can also install the the Devel and Devel kint modules. This will let you debug using kint(xyz).

0

If you only have access to Drush (no Drupal console) and you are working on a remote server, you can set the config to show all errors:

drush MYSITE.MYENV config-set system.logging error_level all -y

This is useful if you are getting a WSOD on a remote server and can't troubleshoot without more info.

  • For the situation described I also highly recommend drush sqlc followed by SELECT * FROM watchdog ORDER BY wid DESC LIMIT 1 to show the last entry in the dblog. – gogowitsch Aug 9 '18 at 19:49
0

Blank page with "The website has encountered an error. Please try again later." won't take you anywhere. To get more information out of your Drupal 8 site you can enable following configs.

$config['system.logging']['error_level'] = 'verbose';

For local Drupal 8 development, you should also enable error reporting, display errors and display startup error to help you further debugging and fixing major runtime error.

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

You can find more information about TWIG debugging and enabling debugging with Drupal Console in the blog post below.

https://www.drupixels.com/blog/enable-debug-mode-and-error-reporting-local-development-drupal-8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.