How to enable syslog in Drupal websites (Performance Optimization)

June 03, 2018

Introduction

Drupal default installation comes with "Database logging" module enabled. Which facilitates you to see the logs on the website itself, with admin role. On the first looks awesome to see the logs in one place, you don't need to move here and there. Drupal Database logging module

Disadvantages of Database logging module

This module logs the debug information in the database table. For every log write, it has to connect to db, write an entry to it. Which is actually slow in operation. It slows down your site significantly, as the table grows.

Alternate to Database logging module - Syslog module

There is an alternate to this module in drupal called "Syslog module", which is also present in the core. But, it is disabled by default. For optimization purpose, you should consider enabling this module, and disabling "Database logging" module.

Challenge to Syslog module

If your website is running in a shared hosting environment, then you will not be able to use syslog module eventually. As, this requires a bit modification in the operating system in which it is running.

How to enable Syslog Module

As the name suggest, it write logs to system logs of operating system. You need to configure your system and tell him where drupal will write its file.
  • Login as admin
  • Goto /admin/config/development/logging
  • Set a system identity (should be unique)
  • Select a syslog facility. It should be a unique one, that no other service is using.
  • For example; you choose LOG_LOCAL6
  • SSH to your webserver (shell access)
  • Open file /etc/syslog.conf OR /etcrsyslog.conf
  • Search for "local". You will see a line something like shown below: This line shows existing configuration of some boot operation.
  • Copy this line, and put a new line below this, and remember to change local7 to local6, the one which you choose in log facility identifier.
  • Also, change the logfile path something like /var/log/drupal.log
  • Save the file.
  • On command line, restart syslog service by:
    service syslog restart RO sysctl restart rsyslog
  • You are all setup
Syslog module of drupal

How to see logs

Navigate to /var/log directory. You should see a file drupal.log which we put in config file of syslog.

You can either do tail -f drupal.log or open it in an editor like vim.

Youtube video

For your reference, I have setup a youtube video for this demonstration.

Similar Posts

Latest Posts