-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Homegenize exception logging between web and console #29138
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
Comments
The reason is that Http exception is console context would be pretty strange. I can totally see that it might happen due to people throwing http exceptions even in places that are not necessarily run in http context at all. But IMO we should not explicitly support this just to make the logging more similar. So 👎 |
Btw, why do you not want to log error logs? |
Hello and thanks for the answer, i agree about http exception in console context, i am not suggesting to check for them in console ErrorListener. I was more thinking about raising the log level to critical in console but it probably has some consequences i don't measure. I use monolog for logging and defined a stack of handlers including a mailer which i want to report only critical (errors are still logged by other handlers in files) |
@nicolas-grekas do you think is there something we could do to improve this ... or should we close it as "won't change"? Thanks. |
No opinion here, maybe we can close because this didn't get enough traction? |
Yes, let's close. My own opinion was 👎 but not very strong ... so let's close. Thanks. |
This PR was merged into the 4.4 branch. Discussion ---------- [Console] Fix console logger according to PSR-3 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #39050, #29138 | License | MIT `Symfony\Component\HttpKernel\EventListener\ErrorListener` logs non-HTTP exceptions at `LogLevel::CRITICAL`. `Symfony\Component\Messenger\Worker` logs unrecoverable exceptions at `LogLevel::CRITICAL`. `Symfony\Component\Console\EventListener\ErrorListener` logs exceptions at `LogLevel::ERROR`. As per PSR-3, unexpected and unrecoverable exceptions should be logged at `LogLevel::CRITICAL`. Commits ------- 69fcd07 Fix console logger according to PSR-3
Description
Hi, currently when an exception is thrown it is handled either by
\Symfony\Component\HttpKernel\EventListener\ExceptionListener
in a web context or\Symfony\Component\Console\EventListener\ErrorListener
in console context.In the web context, the logging happens depending on the exception code and type
In the console context, exception are always logged as errors:
If you configure a logger to log only CRITICAL and above, the exception will be logged in the web context but not in a console context
Is there a particular reason for this difference ? do you think the console ErrorListener could be improved to have a similar behavoir like ExceptionListener ?
Thank you
The text was updated successfully, but these errors were encountered: