saahityaedams

06 Aug 2021

Logging in Drupal

Setting up proper logging today prevents the big headache tommorow

Components

  • syslog - inbuilt drupal module to log drupal errors(no particular reason for choosing this module, can use any appropriate module that logs to file or write a module that implements hook_watchdog)
  • logrotate - to archive the old logs to help classify by data and save space.

Steps

  1. We enable syslog in the modules in drupal and save with the default config
  2. add a file in /etc/rsyslog.d directory called 45-drupal.conf for drupal log specific configuration
  3. add this to file
local0.* /var/log/drupal.log
& ~
  1. restart rsyslog by running sudo service rsyslog restart
  2. Write a configuration file in /etc/logrotate.d/
/var/log/drupal.log {
daily
missingok
rotate 31
compress
notifempty
copytruncate
sharedscripts
}