Drupal7: Logging and Alerts Module

David G - DrupalIn some of my recent websites I’ve had the drive to want to be notified with something is amiss. Or, a dreadful horrible php ERROR has occurred. The reasons for these notifications can be code updates, security vulnerabilities, Debug information on periodic tasks. I took some time and did an informal review of notification modules. I settled on a relatively old, but stable module called Logging and Alerts.

The Logging and Alerts module allows the site administrator to set simple conditions or Rules for Watchdog information to be sent via email per event.

As an example on 2 drupal web applications I run that accept submissions and request feedback I installed this module to know when if my custom code updates broke features I was unable to test fully before update. The other website gets so much traffic and I want to assure its functioning properly and is secure.

The Logging ad Alerts allows me to configure Watchdog levels that should be emailed when a corresponding event is logged. It also allows me to select optional information about the context of the error, such as: $_REQUEST values, $_SERVER values or include a php stacktrace.

Once installed you can goto admin/config/development/emaillog and configure the module (note: I use the watchdog_rules sub module which also requires the Rules module).

Logging and Alerts configuration page options.

Logging and Alerts configuration page options.

Then on events that match your criteria you’re sent an email. Note, you can set throttling rules for these notifications so you don’t drown in thousands of DDOS invalid login attempts for example.

An example of an email (fragment) is:

[] Error: PDOException: SQLSTATE[42000]: Syntax error or access...
1 message
webdev@id.ucsb.edu <webdev@id.ucsb.edu> Mon, Nov 17, 2014 at 11:04 AM
To: webdev@id.ucsb.edu
Site: https://mysite.edu
Severity: Error (3)
Timestamp: 2014­11­17 11:04:35
Type: php
IP Address: 128.111.138.37
Request URI: https://mysite.edu/?q=user/login
Referrer URI:
User: Anonymous (0)
Link:
Message:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You
have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near ' 'test' AND status =
1' at line 1: SELECT * FROM {users} WHERE name = :name_0, :name_1 AND status
= 1; Array
(
[:name_0] => test3
[:name_1] => test
)
in user_login_authenticate_validate() (line 2149 of
/var/www/mysite/htdocs/modules/user/user.module).
$_SERVER => Array
(
[HTTP_HOST] => mysite.edu
[HTTP_X_REAL_IP] => 198.101.235.135
[HTTP_X_FORWARDED_FOR] =>

... lots of more lines of email output ...

In general I think some of the information may be difficult to backtrack and trace code with. But, I think the most important aspects of this utility are:

  1. This is a very mature utility with thousands of downloaded sites using it.
  2. Being aware of these site issues in real-time from the notification emails gives you the situational awareness of immediate issues of your website.

Looking for quality web hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , | Posted under Drupal | RSS 2.0

Author Spotlight

David Gurba

I am a web programmer currently employed at UCSB. I have been developing web applications professionally for 8+ years now. For the last 5 years I’ve been actively developing websites primarily in PHP using Drupal. I have experience using LAMP and developing data driven websites for clients in aviation, higher education and e-commerce. If you’d like to contact me I can be reached at david.gurba@arvixe.com

Leave a Reply

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