Add a killswitch for dblog and syslog

Created on 24 May 2022, over 2 years ago
Updated 23 September 2023, about 1 year ago

Problem/Motivation

Many Drupal agencies host client websites at different hosting providers, each of them doing logging in different ways. Some hosting providers (Acquia, Platform.sh) suggest using Syslog which is more performant, but others (Pantheon) don't support or expose system logs to site owners who are stuck with Dblog in prod. Regardless of prod hosting, we'd love to have developer local environment tooling be standardized as much as possible, easy to use and debug, with minimal additional configurations/setup required. This means local environment should be logging to watchdog logs for ease-of-use (dblog module). Optionally, syslog could be disabled as well on local, but I see no huge harm in leaving it enabled.

Therefore, I'd like a way to have both syslog and dblog modules enabled (in core.extension.yml) and configured (in [dblog|syslog].settings.yml), but then "muted" in specific environments via kill-switch logic in settings.php or settings.local.php, so that I can have syslog running in PROD, but dblog on in LOCAL and DEV all without incurring configuration yml changes.

This will improve developer experience who would want to quickly and easily see the errors in dblog without having to setup syslog handling on local/dev environments. (for example, DDEV doesn't support syslog out of the box).

Also having a kill-switch means less devops procedures such as a post-db-sync task to enable dblog / disable syslog, and also therefore fewer mishaps when developers export and commit configuration changes accidentally committing unrelated actions like enabling dblog in core.extensions.yml which could then get sent up to production, if not careful.

Proposed resolution

Dblog has a row_limit setting which might seem like an obvious kill-switch, until you realize the purpose of row_limit=0 is to disable cron from purging rows in the table.

I would suggest two sister kill-switches, one for syslog and one for dblog:

$disable_dblog = \Drupal::config('dblog.settings')->get('disable_logging');
$disable_syslog = \Drupal::config('syslog.settings')->get('disable_logging');

The configuration would typically be set to disable_logging: false by default, for backward compatibility with sites that may not yet have the value set or undefined/null.

A boolean checkbox could be exposed in their respective module settings forms but for the primary use case this is not required.

Then, developers could turn it off in settings.php conditional logic or in settings.local.php

// if PROD
$config['dblog.settings']['disable_logging'] = TRUE;
$config['syslog.settings']['disable_logging'] = FALSE;

// else if DEV/TEST/LOCAL
$config['dblog.settings']['disable_logging'] = FALSE;
$config['dblog.settings']['disable_logging'] = TRUE;

Remaining tasks

  1. Write patch.
  2. Review and validate approach.
  3. Write release note snippet & change record copy.

User interface changes

None.

API changes

Two additional module settings named "disable_logging" for core syslog and dblog modules.

Data model changes

None

Release notes snippet

TBD

Feature request
Status

Active

Version

10.0

Component
Database Logging 

Last updated about 2 months ago

Created by

🇪🇨Ecuador jwilson3

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024