~ 2 min read

Drupal Database Log to Syslog

share this story on
How to disable the Drupal Database Log and enable Syslog instead

Drupal Database Log is utilizing the built-in watchdog module but it can end up being quite a resource hog if you’re over utilizing it and having many modules enabled, let alone all the PHP warning and errors that it will log – causing an overkill in performance to your database with a lot of writes.

How to disable the Drupal Database Log and enable Syslog instead

Disabling the DB Logging module and enabling Syslog in Drupal 6:

include_once('includes/install.inc');
// Replacing the DB Log module with the Syslog
module_disable(array('dblog'));
drupal_uninstall_module(array('dblog'));
drupal_install_modules(array('syslog'));

This requires further configuration on the Linux side for syslog

  1. edit /etc/syslog.conf – because default settings for the Syslog module on Drupal are set to use local0 then we should set logging from the local0 facility to a dedicated Drupal log file, so we’ll add the following entry:
# Drupal watchdog logging
local0.*        /var/log/drupal.log

By default, Syslog also logs all facilities info level to /var/log/messages. This is both annoying, because it hinders on investigating general system issues in /var/log/messages, as well as un-necessary duplication of data since this information is already stored in /var/log/drupal.log
To disable this behavior we need to tell Syslog to avoid from logging information from local0 to /var/log/messages then,

  1. locate the /var/log/messages entry which should look roughly like this:
*.info;mail.none;authpriv.none;cron.none;           /var/log/messages

and change it into

*.info;local0.none;mail.none;authpriv.none;cron.none;           /var/log/messages

where we specify local0.none and Syslog knows to disregard messages from local0 facility

And finally restart syslog for changes to take effect

/etc/init.d/syslog restart
share this story on