A lightweight Drupal Logger that provides a production-ready structured logging approach, allowing to store 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.
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 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)[https://www.drupal.org/project/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:

Project information
- Project categories: Developer tools, Integrations, Performance
- Ecosystem: Logger
32 sites report using this module
- Created by Yoran on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
Releases
Fixed OpenTelemetry integration
Development version: 1.0.x-dev updated 27 Mar 2026 at 05:29 UTC




