Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Logger

41 sites Security covered
View on drupal.org

This project offers a production-ready logging system for Drupal that stores log entries in JSON format with custom metadata. It supports logging to various destinations like files, stdout, and syslog, and can be extended to support new targets via plugins.

A lightweight Drupal Logger that provides a production-ready structured logging approach, which allows storing any additional metadata as custom fields together with the log entry in JSON format as a nested data structure, with no dependencies on external libraries.

Supports logging to any target: stdout, stderr, file, syslog, database, http, clouds, extendable by plugins to support any new target.

Presentation at the DrupalCon »»»

Features

  • Generates logs in JSON format, including only the fields you want to see, not all the defaults.
  • Allows storing any additional custom metadata together with a log record as a raw nested structure with custom fields.
  • Provides an option to store raw log messages with unreplaced placeholders, storing the placeholder values in separate JSON fields.
  • Works out of the box with no external dependencies.
  • Easily configurable through the Drupal admin panel.
  • Provides the ability to use database-based logging in the local development environment, keeping the production logging without database dependencies, using the Logger DB module.

Installation

Simply install the module and it will start working with the default settings with no special requirements.

To attach metadata to the log entry, you don't need to use anything new! Just use the standard PSR-3 Logger Interface and attach your custom fields as a free-form nested array to the $context['metadata'] like this:

 $logger->log(
  level: LogLevel::INFO,
  message: 'My custom operation',
  context: [
    'metadata' =>
      'any' => [
        'structured' => [
          'data' => 'here',
        ]
      ]
    ]
  ]
);

By default, the module stores logs in the file temporary://drupal-log.jsonl to make it work on any environment out of the box. But logging to files is not an optimal way for performance reasons, therefore it's better to change the default output target and other settings on the page Configuration » Development » Logger (path /admin/config/development/logger).

Recommended Logging Approach

For production: the best approach is to output logs to stderr, which can be captured and parsed by a log scraper such as Grafana Loki, Fluentd, the ELK Stack (Elasticsearch, Logstash, Kibana), OpenTelemetry Logs, Promtail, Splunk, Datadog, Graylog, Logz.io, and others.

For testing and local environments: the most convenient way is to store logs in the Drupal SQL database. This functionality is provided by a separate module, Logger DB, to keep the base module minimal, lightweight, and suitable for production.

You can switch the log target on the fly per environment by overriding the config value in the settings.php like this:

if (getenv('SITE_ENV') !== 'production') {
  $config['logger.settings']['targets'][0]['plugin'] = 'database';
  $config['logger.settings']['targets'][0]['configuration'] = '{}';
}

Additional modules

  • Logger DB: stores logs directly in the Drupal database.
  • Logger Entity: creates Drupal entities for each log entry, providing the ability to link log entries with other Drupal entities using custom entity reference fields.
  • Request Logger: logs every request to Drupal with performance metrics (duration, memory usage, cache status, etc).

Similar Projects

There is a similar module Monolog that provides the ability to store custom metadata together with the log entries.

In comparison with the Monolog, the Logger module provides a more simple and lightweight implementation, compatible with other Drupal Loggers, and in conjunction with the Logger DB module provides viewing logs with all custom fields and metadata directly in the Drupal admin panel.

And the "Monolog" provides more customizations on the log processing, filtering and persisting sides, so it is a good choice if you need more control on your log entries.

And there are some modules that provide extended logging for Drupal, like these:

However, all of them only store the log message text in the log entry, with no way to store additional structured data.

Supporting this Module

You can show your appreciation for the development of this module and motivate further work through these services:

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
7
Tracked since
Sep 2025
Latest release
5 months ago
Releases (12 mo)
7 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.0.0-alpha6 Pre-release 10–11 Mar 27, 2026
1.0.0-alpha5 Pre-release 10–11 Mar 26, 2026
1.0.0-alpha4 Pre-release 10–11 Mar 10, 2026
1.0.0-alpha3 Pre-release 10–11 Oct 13, 2025
1.0.0-alpha2 Pre-release 10–11 Oct 11, 2025
1.0.0-alpha1 Pre-release 10–11 Sep 15, 2025
1.0.x-dev Dev 10–11 Sep 9, 2025