Section 2: Drupal Logs

The default core Drupal distribution has two primary logs. Each of these logs can be quite useful in troubleshooting and developing your website, but as your website grows you need to tune these logs to prevent them from causing performance issues.

Watchdog Logs

Prior to Drupal 6 the core distribution included a module called the "watchdog". In Drupal 6 the module has been renamed to dblog, but the watchdog() logging function still retains the same name. As the name suggests, the dblog module writes logs to the database. The module's help text explains, "the dblog module monitors your website, capturing system events in a log to be reviewed by an authorized individual at a later time. The dblog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. It is vital to check the dblog report on a regular basis as it is often the only way to tell what is going on."

As your website grows, writing logs to the database can increasingly become a performance bottleneck. For this reason in Drupal 6 the core distribution also includes the syslog module which can replace the default dblog module, routing watchdog logs to the operating system's logging facility. As your website grows, syslog can offer significantly better performance. These logs are no longer easily viewed through a web browser with Drupal, however they cause significantly less performance overhead and they can be safely retained much longer. The syslog module's help text explains, "syslog is an operating system administrative logging tool, and provides valuable information for use in system management and security auditing. Most suited to medium and large sites, syslog provides filtering tools that allow messages to be routed by type and severity. On UNIX/Linux systems, the file /etc/syslog.conf defines this routing configuration; on Microsoft Windows, all messages are sent to the Event Log."

The Access Log

The Drupal Access Log is provided by the core statistics module. When this log is enabled, each time Drupal displays a page it logs the session ID of the user visiting the page, the title of the page visited, the internal Drupal path, the complete URL, the IP address of the visitor, the user ID of the visitor, the length of time it took Drupal to display the page, and a timestamp as to when the page was actually displayed. Drupal can then provide several useful administrative reports from this data.

As a website grows in popularity, the amount of data being written to the accesslog can quickly become an unnecessary performance bottleneck. It can help to configure Drupal to discard old access logs more frequently, minimizing the size of the accesslog database table. However, from a performance standpoint the best thing to do is to completely disable the statistics module and instead utilize the logs provided by your web browser.