symfony / monolog-bundle

Symfony Monolog Bundle
symfony.com
MIT License
2.9k stars 232 forks source link

No log generated when using excluded_http_codes with some sub handlers under group (symfony/monolog-bundle 3.x). #462

Open fodger opened 1 year ago

fodger commented 1 year ago

This configuration for monolog stops generation of logs in var/log/ when adding excluded_http_codes: [404]. When we disable it, it works.


monolog:
  handlers:
    main:
      type:  fingers_crossed
      path:  '%kernel.logs_dir%/%kernel.environment%.log'
      level: warning
      excluded_http_codes: [404]
      channels: ['!event']
      handler: grouped
    grouped:
      type:    group
      members: [streamed, deduplicated]
    streamed:
      type:  rotating_file
      path:  '%kernel.logs_dir%/%kernel.environment%.log'
      level: warning
      max_files: 5
    deduplicated:
      type:    deduplication
      handler: symfony_mailer
    symfony_mailer:
      type:       symfony_mailer
      from_email: '%env(MAILER_MONOLOG_ADDRESS)%'
      to_email:   '%env(MAILER_MONOLOG_ADDRESS)%'
      subject:    '[%kernel.environment%-ERROR] %%message%%'
      level:      warning
      formatter:  monolog.formatter.html
      content_type: text/html
    console:
      type: console

Using a simpler configuration, its works properly such as :

monolog:
  handlers:
    main:
      type:  fingers_crossed
      path:  '%kernel.logs_dir%/%kernel.environment%.log'
      level: warning
      channels: ['!event']
      handler: grouped
      excluded_http_codes: [404]
    grouped:
      type:    group
      members: [streamed]
    streamed:
      type:  rotating_file
      path:  '%kernel.logs_dir%/%kernel.environment%.log'
      level: warning
      max_files: 5
stof commented 1 year ago

what do you mean by "it stops generation of logs" ? Do you mean that 404 responses are not logged anymore ? that's kind of expected if you exclude them in the activation strategy of the fingers_crossed (and there is no other error activating the fingers_crossed in that request)

fodger commented 1 year ago

I mean all errors codes are excluded with fingers_crossed. Please try !!!

fodger commented 12 months ago

Any definitive answer please ?