Search by

drupal / govnl_cms_logging

Drupal-Infrastructure

There is no license information available for the latest version (1.0.2) of this package.

Enables Logging functionality for GovNL CMS projects.

Package info

git.drupalcode.org/project/govnl_cms_logging.git

Homepage

Issues

Type:drupal-recipe

pkg:composer/drupal/govnl_cms_logging

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

1.0.2 2026-09-17 07:22 UTC

This package is auto-updated.

Last update: 2026-09-17 05:24:12 UTC


README

This recipe enables the Logging settings used in GovNL CMS projects.

Read the documentation of the GovNL recipes setup carefully before installing this recipe.

Submit bug reports and feature suggestions, or track changes in the issue queue.

Requirements

This module requires the following modules:

Installation

Install as you would normally install a contributed Drupal recipe. For further information, see How to Download and Apply Drupal Recipes.

Configuration

The GovNL Logging module provides Monolog processors, a JSON formatter, and a Sentry event subscriber. To use these services, configure your monolog.services.yml file.

  1. Open or create sites/default/monolog.services.yml.
  2. Register the custom processors (request_id, app_context) under parameters.monolog.processors or per handler.
  3. Assign the toplevel_json formatter to your log handlers (e.g. stdout).
  4. Make sure the monolog.services.yml is included in settings.php using $settings['container_yamls'][] = 'sites/default/monolog.services.yml';

Example monolog.services.yml configuration:

parameters:
  monolog.channel_handlers:
    default:
      handlers:
        - name: 'drupal.dblog'
        - name: 'drupal.raven'
          processors: ['current_user', 'request_uri', 'ip', 'referer']
        - name: 'stdout_debug'
          formatter: 'toplevel_json'
    system:
      handlers:
        - name: 'drupal.dblog'
        - name: 'drupal.raven'
          processors: ['current_user', 'request_uri', 'ip', 'referer']
        - name: 'stdout_warning'
          formatter: 'toplevel_json'
  monolog.processors:
    - 'message_placeholder'
    - 'current_user'
    - 'request_uri'
    - 'ip'
    - 'referer'
    - 'request_id'
    - 'app_context'

services:
  monolog.handler.stdout_debug:
    class: Monolog\Handler\StreamHandler
    arguments: ['php://stdout', 'DEBUG']

  monolog.handler.stdout_warning:
    class: Monolog\Handler\StreamHandler
    arguments: ['php://stdout', 'WARNING']

Environment variables

The app_context processor automatically reads the following environment variables to enrich log entries:

  • ENVIRONMENT: Deployment environment name (for example: production, staging, test, review).
  • RELEASE_SERVICE: Service name (for example: gwp-frontend).
  • HOSTNAME: Container hostname or Kubernetes pod name.
  • RELEASE_HOSTNAME: Hostname used as a fallback to detect the environment when the ENVIRONMENT variable is not set.

Request correlation

The request_id processor correlates log records during an HTTP request:

  • If an incoming X-Request-ID HTTP header is present, its value is used.
  • If no header is present, a 32-character hexadecimal ID is generated.
  • The request ID is cached in the request attribute _request_id throughout the request lifecycle.