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