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.
Download the Logging and alerts module and enable the “Email logging and alerts” sub-module.
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.
Here is what the generated email looks like:
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.
When the email is sent out, the global variables are printed below the main message in the email.
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.
2 thoughts on “Receive Drupal Log and Alert Notifications Via Email”
Cool, I will take at closer look at this 🙂
Very nice module that I had no idea existed, thanks for sharing!