How to Display Errors in Drupal

Have you seen an error message in a Drupal site like this?

When you are building or modifying a Drupal site, the error above can sometimes appear and catch us in unexpected situations, but there is nothing much you can do. “Try again later” is not going to help. What will you do?

There is not much you can do about it, because there is not enough information to go further. By default, Drupal is configured not to display error messages. To find out what caused the errors, the error message display options require to be turned on first.

In this tutorial, you’ll learn how to turn on error display to help you debug.

WARNING: It’s important not to display error messages on a production site. The error messages could display sensitive information such as paths or server level user accounts.

How to Display Errors

To turn on the “Error Messages to Display”, go to the Administration menu, then go into Configuration > Development > Logging and errors (/admin/config/development/logging).

You will find the following configuration. There are 4 options available, and the default setting is “None”.

The 4 options are:

None

None is the default. Drupal will not display error messages. That’s why there is only very limited error information displayed.

Errors and warnings

Display both errors and warnings

All messages

Display all messages

All messages, with backtrace information

Display all messages, including a backtrace of all the functions that the system has gone through before the error

Turning on the other options, Drupal will display more error messages. The following is another example of error messages after turning on “All messages, with backtrace information”:

When more information is provided, it’s easier to isolate, test and identify what really caused the errors. Compared with the first error screen above, this one makes much more sense to start with. We are not going into the individual errors here. This is probably the first step to handle unknown error messages. Even though sometimes we need help from other people, this more detailed information is still necessary for them to follow up.

Recent Log Messages

In addition to the error screen, there is an area “Recent Log Messages” we can look into if the site is still working.

To go into this area, go to Administration Menu, go to Reports > Recent log messages (../admin/reports/dblog),

A list of recent log messages can be found here. Following is an example:

By clicking on the individual log, more details of that error message will be displayed. Below is an example.

Summary

Next time when we come across a run-time error, we can analyze what changes have been made, see if the errors are repeating, and see if things can be reversed.

In addition, turning on these error message displays to provide us more information, particularly a backtrace of the functions Drupal was executing, and collecting other log messages are additional steps we can take.

Even though we might need assistance from other people, this information is still important to them.

We hope these simple steps will be helpful in problem-solving, which sometimes can be very time-consuming.

About The Author

2 thoughts on “How to Display Errors in Drupal”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top