Issue fork monolog-3157611

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

    Support from Acquia helps fund testing for Drupal Acquia logo

    Comments

    cosolom created an issue. See original summary.

    cosolom’s picture

    Status: Active » Needs review
    FileSize
    943 bytes
    lussoluca’s picture

    Status: Needs review » Active

    Pls describe why we need this change

    cosolom’s picture

    Without this change I got error "Level "100" is not defined, use one of: 100, 200, 250, 300..."

    msti’s picture

    Status: Active » Reviewed & tested by the community
    FileSize
    22.56 KB

    I am also having this error, see attached screenshot.
    My configuration: core 8.9.2, drupal/monolog 2.0.0-beta1 and monolog/monolog 2.1.0

    The patched #2 fixes the error.

    pdenooijer’s picture

    RTBC +1

    The problem is they are defined as strings in the services file, but they should be defined as integers instead. The setLevel method does this in Monolog\Logger:

    if (is_string($level)) {
      // Contains chars of all log levels and avoids using strtoupper() which may have
      // strange results depending on locale (for example, "i" will become "İ" in Turkish locale)
      $upper = strtr($level, 'abcdefgilmnortuwy', 'ABCDEFGILMNORTUWY');
      if (defined(__CLASS__.'::'.$upper)) {
        return constant(__CLASS__ . '::' . $upper);
      }
    
      throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', array_keys(static::$levels)));
    }
    

    So it assumes it's a constant defined on the class instead of the log level we want. Please commit this for beta2.

    • lussoluca committed 5e7406f on 2.x authored by cosolom
      Issue #3157611 by cosolom, msti: Level "100" is not defined, use one of...
    lussoluca’s picture

    Status: Reviewed & tested by the community » Fixed

    Committed and pushed to 2.x, thanks!

    I'm going to release a beta2.

    Status: Fixed » Closed (fixed)

    Automatically closed - issue fixed for 2 weeks with no activity.

    mhmd’s picture

    The issue still exist in beta 2, See #6.

    pdenooijer’s picture

    It does not, for me beta2 works fine without a patch. So if you still see the problem your probably not on beta2.

    SalvadorP’s picture

    Seems that there is a different, possibly related error.

    I'm seeing this:
    Level "monolog.level.debug" is not defined, use one of: 100, 200, 250, 300, 400, 500, 550, 600

    Checked the values on services.monolog.yml and they are integers, also checked the version in composer and I'm on beta 2.

    "name": "drupal/monolog",
                    "url": "https://git.drupalcode.org/project/monolog.git",
                    "url": "https://ftp.drupal.org/files/projects/monolog-2.0.0-beta2.zip",
                    "monolog/monolog": "^2.0.0"
    

    Is a problem on my side?
    Should I open a new bug, or it is related to the old one?

    manojapare’s picture

    Still the error appears on beta2 version:

    Level "monolog.level.debug" is not defined, use one of: 100, 200, 250, 300, 400, 500, 550, 600, DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY

    Will find out the reason why it is appearing, if valid can reopen this bug.

    manojapare’s picture

    This issue was reproducible only when using composer drupal/core and not while using drupal/core-recommended

    So it should be related or because of some vendor library.

    vladutstoicoiu’s picture

    I had also encounter this issue after I updated to drupal 9.x.
    The problem was that inside the site specific services.yml (Eg: monolog.services.yml) the configuration

    services:
      monolog.handler.rotating_file:
        class: Monolog\Handler\RotatingFileHandler
        arguments: ['private://logs/debug.log', 10, '%monolog.level.debug%']
    

    had "monolog.level.debug" instead of "%monolog.level.debug%".
    Hope it helps.

    bfuzze9898’s picture

    #15 works... sort of.
    It works AFTER monolog is installed, but it breaks on install/uninstall with the error:

    You have requested a non-existent parameter "monolog.level.debug".

    If I switch it back to 'monolog.level.debug', then I can install/uninstall.
    This is causing some issues with deployments. I think this issue should be reopened.

    UPDATE: Just figured out that combining patch from #2 and #15 fixes both the notice and install/uninstall.

    botanic_spark’s picture

    I am having the issue when installing the module if I have handler defined like this:

    services:
      monolog.handler.rotating_file:
        class: Monolog\Handler\RotatingFileHandler
        arguments: ['private://logs/drupal.log', 10, '%monolog.level.debug%']
    

    The error I am getting
    You have requested a non-existent parameter "monolog.level.debug".