-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Document new Monolog HTTP code exclusion feature #8235
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
Document new Monolog HTTP code exclusion feature #8235
Conversation
… for ignoring specific HTTP codes (simshaun, fabpot) This PR was merged into the 4.1-dev branch. Discussion ---------- [Monolog Bridge][DX] Add a Monolog activation strategy for ignoring specific HTTP codes | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9712 | License | MIT | Doc PR | symfony/symfony-docs#8235 This PR introduces a Monolog activation strategy that makes it easy to ignore specific HTTP codes. e.g. Stopping logs from being flooded with 403s, 404s, and 405s. Relevant Symfony integration PR on symfony/monolog-bundle: symfony/monolog-bundle#221 Commits ------- 6fc1cc3 added some validation c11a8eb Add a Monolog activation strategy for ignoring specific HTTP codes
Hey @simshaun! Thanks for the awesome feature - this was totally missing! To the docs! We already have an article about excluding 404’s. I think we should actually remove that article and put your new content into a new section in the main logging.rst article (you can just do the second part - we can discuss deleting that 404 article later). Also, have you considered adding this to the monolog recipe? We use exclude_404’s there currently. But I think this should completely replace that. Cheers! |
type: fingers_crossed | ||
handler: ... | ||
excluded_http_codes: [403, 404, { 400: ['^/foo', '^/bar'] }] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should use the multi line format - one status code per line - I think it will be more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this suggestion because I like how compact this looks ... but I don't have a strong opinion about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind either way. I think multi-line might be a little clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the preferred format for multi-line arrays in YAML?
A:
excluded_http_codes: [
403,
404,
{ 400: ['^/foo', '^/bar'] }
]
or B:
excluded_http_codes:
- 403
- 404
-
400:
- ^/foo
- ^/bar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weaverryan don't you think the expanded format is less readable in this case? The empty space in the last element in the B) notation is confusing ... and the A) format is a bit confusing too because of the way the brackets are displayed.
Also, can you switch your branch to be against master? |
==================================================================== | ||
|
||
Sometimes your logs become flooded with unwanted HTTP errors, for example, | ||
403s and 404s. When using a ``fingers_crossed`` handler, you can exclude |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question: is the mention of the fingers_crossed
handler just an example or does this feature only work with that specific handler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I based the feature off of NotFoundActivationStrategy, which is only for fingers_crossed
|
||
.. code-block:: yaml | ||
|
||
# app/config/config.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to update the file paths for Symfony 4: app/config/config.*
-> config/packages/monolog.*
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually haven't gotten to mess with Symfony 4 much yet, but I just installed symfony/website-skeleton
to look. It looks like it has:
config/packages/dev/monolog.yml
config/packages/prod/monolog.yml
config/packages/test/monolog.yml
I don't see one just in config/packages/
. Should I just update the comment to something like:
# config/packages/{{env}}/monolog.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Let's add prod
environment in the example because most of the times you only care about configuring logs in prod (and we use prod
in most of the examples in the docs). Also, beware that in Symfony 4 the file extension is .yaml
instead of .yml
Thanks!
type: fingers_crossed | ||
handler: ... | ||
excluded_http_codes: [403, 404, { 400: ['^/foo', '^/bar'] }] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this suggestion because I like how compact this looks ... but I don't have a strong opinion about this.
3db3ef3
to
e19bca2
Compare
I've rebased against master & added a couple comments above. |
I think the current file,
I hadn't. That would be https://github.com/symfony/recipes/blob/master/symfony/monolog-bundle/3.1/config/packages/prod/monolog.yaml right? |
This PR was squashed before being merged into the 4.0 branch (closes #9621). Discussion ---------- Fixed the paths of the Monolog config files After reading this comment: #8235 (comment) I realized that some config paths are wrong for Monolog because the recipe (https://github.com/symfony/recipes/tree/master/symfony/monolog-bundle/3.1/config/packages) doesn't create any config file in `config/packages/monolog.yaml` (all files are defined per environment). Most of the examples used `config/packages/prod/monolog.yaml`, so I used that too. It makes sense tome because you usually only carefully configure logs in `prod`. The only article where we maintain `config/packages/dev/monolog.yaml` would be `logging/monolog_console.rst` where I think it makes sense. Commits ------- 9de898a Fixed the paths of the Monolog config files
Hmm, actually, your new feature in MonologBundle hasn't been released yet on MonologBundle. So, we need to wait for that. But then, it will probably be version 3.3 of MonologBundle. So, we would actually need to duplicate/create a new 3.3 directory from the 3.1 directory, with the new config. But that's ok (the duplication), that's just how the recipe system works.
Fine by me :). Let's completely replace that document with your new documentation :) |
How to Configure Monolog to Exclude Specific HTTP Codes from the Log | ||
==================================================================== | ||
|
||
Sometimes your logs become flooded with unwanted HTTP errors, for example, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a versionadded here:
..versionadded:: 4.1
The ability to exclude status codes was introduced in Symfony 4.1 and MonologBundle 3.3.
I'm guessing on the 3.3 part for MonologBundle, but unless something super strange happens, that should be true.
Shaun, thanks for contributing the docs for this new feature! We're sorry it took us so long to merge it. |
…n, javiereguiluz) This PR was merged into the 4.1 branch. Discussion ---------- Document new Monolog HTTP code exclusion feature I'm submitting PRs on symfony/symfony and symfony/monolog-bundle that introduces an easy way of excluding specific HTTP codes from Monolog. This PR documents that new feature, pending its acceptance. Pending PRs: symfony/symfony#23707 symfony/monolog-bundle#221 Commits ------- 30cc7d4 Added the versionadded directive c8c19f2 Update to Symfony 4 paths e19bca2 Fix indentation 17cb416 Update configuration format to support URL blacklist c9f6ee5 Fix title underline length a3b6a01 Document new Monolog HTTP code exclusion feature
I'm submitting PRs on symfony/symfony and symfony/monolog-bundle that introduces an easy way of excluding specific HTTP codes from Monolog.
This PR documents that new feature, pending its acceptance.
Pending PRs:
symfony/symfony#23707
symfony/monolog-bundle#221