monolog_logz
Ship logs to Logz.io via Monolog. This glue module allows shipping handler provided by the logzio-monolog library to be exposed to the Drupal Monolog module and configured using the Drupal config system.
Features
- Registers a
monolog.handler.logzservice that can be then configured into the monolog service. - Sources handler configuration from the Drupal configuration system under a
monolog_logz.settingsconfiguration item.
Due to #2951046: Allow parsing and writing PHP class constants and enums in YAML files, it is not currently possible to configure the logzio-monolog library's handler directly in a Drupal services.yml file as the library specifies PHP Enumerations as arguments and Drupal is not setting the YAML parser flags in a way that allows these typed arguments.
Even if passing enums in a Drupal services.yml were possible, it is a common pattern to configure site-specific values in settings.php or the Drupal config system. Some users may not wish to hard-code their Logz.io token in a *.services.yml file but rather inject it via the environment or a secrets-management system.
Post-Installation
Like the Monolog module, this module does not have any visible user interface and is configured by adding values to the Drupal configuration, usually in settings.php. Additionally you must tell monolog to use it in a monolog.services.yml (or equivalent) file used to configure monolog (as described in the Monolog module's README).
- Install this module (and the Monolog module) with composer to ensure you are also getting the logzio-monolog library.
- Add your configuration details to your
settings.php:
// Part of the Monolog module setup: $settings['container_yamls'][] = 'sites/default/monolog.services.yml'; // Configure the Logz.io shipping handler: $config['monolog_logz.settings']['token'] = 'my-logz.io-token'; $config['monolog_logz.settings']['level'] = 'Debug'; $config['monolog_logz.settings']['host'] = 'UsEast1'; - Configure the logz handler provided by this module into the monolog service in a
monolog.services.yml:
parameters: monolog.channel_handlers: php: ['error_log', 'logz'] default: ['logz']
Additional Requirements
- Drupal Monolog module (installed as a dependency with composer)
- logzio-monolog library (installed as a dependency with composer)
- An account and subscription at Logz.io to send the logs to.
- A log-shipping token associated with your account.