Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

excluded_http_codes might not work properly #271

Closed
Sengorius opened this issue Jun 15, 2018 · 5 comments
Closed

excluded_http_codes might not work properly #271

Sengorius opened this issue Jun 15, 2018 · 5 comments
Labels
Milestone

Comments

@Sengorius
Copy link

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 4.1

I'm currently using monolog to get informed about errors from a multi-user-site. For my current setup I used https://symfony.com/blog/new-in-symfony-4-1-ignore-specific-http-codes-from-logs as resource.

As you can see below, I tried to exclude 403 and 404 errors (especially) from mailing handler. As for all 404 it might work, but I'm still receiving mails on any 403 error.

# config/packages/prod/monolog.yaml
monolog:
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            handler: grouped
            excluded_http_codes: [403, 404]

        grouped:
            type: group
            members: [nested, mailer]

        nested:
            type: rotating_file
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
            max_files: 30

        mailer:
            type: deduplication
            handler: swift_mail

        swift_mail:
            type: swift_mailer
            from_email: '%env(MAILER_DEFAULT_MAIL)%'
            to_email: '%env(MAILER_SERVICE_MAIL)%'
            subject: 'Exception in M-OBS: %%message%%'
            level: debug
            formatter: monolog.formatter.html
            content_type: text/html
            excluded_http_codes: [403, 404]

        console:
            type: console
            process_psr_3_messages: false
            channels: ["!event", "!doctrine"]

Can you please fix this or is it my error?

@JohJohan
Copy link

JohJohan commented Jul 17, 2018

@Sengorius i can also confirm this, i think excluded_http_codes is only available for fingers_crossed type handler. I have tried to implement it for the slack handler and it also ignores it.

@javiereguiluz
Copy link
Member

When we documented this feature, I asked the same. See: symfony/symfony-docs#8235 (comment) Apparently this is for some technical reason ... but personally it doesn't make any sense to me. This should work for all handlers.

@Seldaek
Copy link
Member

Seldaek commented Dec 26, 2018

Other handlers have no way to filter records.. so you need to wrap them in a fingers crossed handler, which can contain a group handler with all other handlers in it if you want to filter 403/404s from all handlers for example. Fixing this would require generating fingers crossed handler instances on the fly around every handler configured with excluded_http_codes, which sounds nasty to me.

Marking as a bug though because the bundle should error in case this config value is used on a handler that doesn't support it.

@Seldaek Seldaek added this to the 3.3 milestone Dec 26, 2018
@Seldaek Seldaek added the Bug label Dec 26, 2018
@boris-brtan
Copy link

boris-brtan commented Jun 20, 2019

is that change backward compatible ? @Seldaek

@drzraf
Copy link

drzraf commented Dec 5, 2019

Reaching that bug for the same use-case I'm wondering:

Why type=filter doesn't provide these http-code options, and more importantly why is there two similar handlers:

  • filter
  • fingers_crossed
    each having with a different set of option names (fingers_crossed simply seems more powerful).
    I think this needs documenting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants