Attempting to reference monolog services during site installation does not work

Created on 18 July 2024, 5 months ago

Problem/Motivation

Maybe just a gap in the documentation, but should the added `monolog.services.yml` attempt to reference services provided by the module proper, and `settings.php` is configured to make use of such `monolog.services.yml` at install time, site install fails.

Steps to reproduce

Place/configure `settings.php`, with a `monolog.services.yml`, as described under "Conditional Handlers" (including the `DrushLoggerServiceProvider` bit): https://git.drupalcode.org/project/monolog/-/tree/3.0.x?ref_type=heads#c...

Attempting to install the site the results an exception such as:

In CheckExceptionOnInvalidReferenceBehaviorPass.php line 119:
                                                                                                                                                
  The service "monolog.handler.default_conditional_handler" has a dependency on a non-existent service "monolog.handler.drupal.drupaltodrush".  

Proposed resolution

Update or provide additional example in README about how it might be necessary and how to prevent the use of the monolog configuration during site installation.

Remaining tasks

- Make the change.
- Review
- Merge
- Release

User interface changes

N/A.

API changes

N/A.

Data model changes

N/A.

📌 Task
Status

Active

Version

3.0

Component

Documentation

Created by

🇨🇦Canada adam-vessey PE, Canada

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

Comments & Activities

  • Issue created by @adam-vessey
  • 🇨🇦Canada adam-vessey PE, Canada

    In terms of what I used in our `settings.php`, something like:

    if (!\Drupal\Core\Installer\InstallerKernel::installationAttempted()) {
      $GLOBALS['conf']['container_service_providers'][] = \Drush\Drupal\DrushLoggerServiceProvider::class;
      $settings['container_yamls'][] = __DIR__ . '/monolog.services.yaml';
    }
    

    Appeared to do the trick, but not sure how or where it would make sense to tie this into the documentation.

  • 🇨🇦Canada adam-vessey PE, Canada

    This seems related to https://www.drupal.org/project/monolog/issues/3346731 🐛 Functional test error service not found for one of the monolog services. Active , where the issue is more one of attempting to reference services provided by modules in general during site installation, where 3346731 was attempting to make use of dblog's logger.dblog service.

Production build 0.71.5 2024