Receive Drupal Log and Alert Notifications Via Email

When you update Drupal core or any contributed module, it’s a good idea to review the Recent log messages page (admin/reports/dblog) a few hours after the update. You want to make sure that there are no major PHP errors being generated after a deployment.

You can also use the log page to see who has logged in, modified content or created a comment. Often when I have to fix a bug on a production site, the Recent log messages page is the first place where I start my investigations.

But keeping track of the recently generated logs can be difficult, this is where you should look at using the Logging and alerts module to setup email notifications.

The Logging and alerts module is a suite of sub-modules that add extra functionality to Drupal’s logging system.

In this article, we’ll look at the “Web server logging and alerts” sub-module. This sub-module will send an email to a configured email address if a log is generated.

Getting Started

Download the Logging and alerts module and enable the “Email logging and alerts” sub-module.

Fig 1.0

The module ships with three other sub-modules, however for this article we’ll just focus on “Email logging and alerts”.

Configure Email Addresses

Now all you need to do is add email addresses to specific log severities like critical, error, warning and more.

1. Go to Configuration -> “Email logging and alerts”(admin/config/system/emaillog).

2. Add an email address to a specific severity or if you want to add multiple addresses, separate them with a comma.

Fig 1.1

Here is what the generated email looks like:

Fig 1.2

Debug Information

You can also have specific global variables printed in the email. This can really help with debugging PHP problems.

Just click on the “Additional debug info” field-set and select which variable should be attached to an email.

Fig 1.3

When the email is sent out, the global variables are printed below the main message in the email.

Fig 1.4

One final note, some of you may be thinking that you can do this with the Rules module, and yes you can. However, the biggest benefit of this module is the “Additional debug info” area and being able to print a variable is very useful.

If you have any questions, please leave a comment.

Ivan Zugec

About Ivan Zugec

Ivan is the founder of WebWash and spends most of his time consulting and writing about Drupal. He's been working with Drupal for 12 years and has successfully completed several large Drupal projects in Australia.

2 thoughts on “Receive Drupal Log and Alert Notifications Via Email”

Leave a Comment

You have to agree to the comment policy.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Media Management in Drupal

Download a FREE 8 part video course on managing media in Drupal.