Enable verbose error logging

Last updated on
25 March 2025

This documentation needs review. See "Help improve this page" in the sidebar.

Sometimes, you can face an unexpected error in a Drupal website, for example during installation, development or updating:

The website encountered an unexpected error. Please try again later.

You can enable backtracing of the error, and display of more information in the message area, via the GUI or by adding a single line in a settings file.

Configure debugging via browser

Navigate to Administration > Configuration > Development Logging and errors > Error messages to display (/admin/config/development/logging) and select the level of Error messages to display (config variable names added for reference):

  • None - hide
  • Errors and warnings - some
  • All messages - all
  • All messages, with backtrace information - verbose

Click "Save configuration"

Configure debugging via Drush

You can enable debugging with Drush as well. See the four possible config variable names above:

drush config:set system.logging error_level verbose -y

Configure debugging via a settings file

Detailed backtracing and message level can also be enabled via a settings file, in one of two ways:

  1. Add it in a new settings.local.php file, creating it by copying sites/example.settings.local.php and rename it to sites/default/settings.local.php. Make sure settings.local.php file is loading by uncommenting the relevant lines in settings.php
  2. Add it in settings.php

Add this:

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

Enable display of PHP errors

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

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

Help improve this page

Page status: Needs review

You can: