-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel][DX] Allow the log level of http exceptions to be overridden #25533
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
Conversation
src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
Outdated
Show resolved
Hide resolved
59d8bb4
to
f361cec
Compare
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 i'd be in favor or 4xx logged as WARNING, that would save us some regular log filtering :-)
for the framework config; should it be semantic? framework.http_exception.log_levels
or so?
src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
Outdated
Show resolved
Hide resolved
Done - how does this impact BC?
Yes that makes a lot more sense. |
e67cb94
to
3a8f92f
Compare
I've just implemented the configuration changes, for example it currently looks something like twig:
http_exception_log_levels:
404: INFO
403: NOTICE I'll need some guidance on how to make this configurable via the framework bundle rather than the twig bundle @ro0NL. Actually it seems pretty weird to me that the twig bundle is responsible for logging http exceptions... any reason behind that, or just an accident of history? |
10de391
to
ed7c409
Compare
src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
Outdated
Show resolved
Hide resolved
Agree, and it's the way it's always has been AFAIK. Note recently we decoupled logging from rendering into different priorities (see #25366), perhaps now we should favor 2 different listeners instead (logging in the framework bundle, rendering in the twig bundle). cc @fabpot |
5510bba
to
a527afe
Compare
Looking at this, but might be tricky to do in a BC way |
87ac731
to
89c2dee
Compare
I've had an initial stab at splitting the listener into two.
I've left the original ExceptionListener in place for BC, although it's no longer used by the framework. Any suggested strategy to deal with BC for old services? And what's the BC policy for service names? Is it OK to remove old service names? |
And the config looks like
|
9b9ee9e
to
a7c5bdf
Compare
OK this is ready for further feedback @ro0NL @nicolas-grekas @sstok. I'm not sure why the tests on php 7.2 are failing though 😕 |
This reverts commit a203d31.
I've rebased on the latest master, any feedback? |
@yceruto Maybe you can help here. |
We've just moved away from |
I won't get a chance to revisit this. If anyone else reading this wants to pick this up, feel free! |
This allows the log level to be configured based on the specific HTTP status code.
This is an alternative approach to #23707. The problem with the approach in #23707 (and with the documented approaches to filter 404s) is that it only works with the fingers crossed handler. However the fingers crossed handler introduces unwanted behaviour, adds complexity to the log configuration, and can be confusing for a developer.
This PR takes a more direct approach. The actual problem is that different applications have different requirements as to what level a specific http code should be logged at. So this makes this behaviour directly configurable.