Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpKernel][Console] Inconsistent logging between the components #39050

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

Closed
alex-dev opened this issue Nov 10, 2020 · 3 comments
Closed

[HttpKernel][Console] Inconsistent logging between the components #39050

alex-dev opened this issue Nov 10, 2020 · 3 comments

Comments

@alex-dev
Copy link
Contributor

alex-dev commented Nov 10, 2020

Symfony version(s) affected: 3.4, 4.4, 5.x

Description
Symfony\Component\HttpKernel\EventListener\ErrorListener logs non-HTTP exceptions as LogLevel::CRITICAL.
Symfony\Component\Console\EventListener\ErrorListener logs exceptions as LogLevel::ERROR.

This is incoherent. Both listeners should log non-HTTP exceptions at the same level.

Possible Solution
Correcting Symfony\Component\Console\EventListener\ErrorListener so it logs at LogLevel::CRITICAL.

@micheh
Copy link
Contributor

micheh commented Nov 15, 2020

See also #29138

@chalasr
Copy link
Member

chalasr commented Dec 12, 2020

I'm closing this issue for the reasons given in #29138.

@chalasr chalasr closed this as completed Dec 12, 2020
@alex-dev
Copy link
Contributor Author

alex-dev commented Dec 18, 2020

Reasons given in #29138 do not address the issue at all.

  • Symfony\Component\Messenger\Worker logs its unrecoverable errors at LogLevel::CRITICAL.
  • Symfony\Component\HttpKernel\EventListener\ErrorListener logs its unrecoverable errors at LogLevel::CRITICAL.

Why would Symfony\Component\Console\EventListener\ErrorListener have another behaviour?
Here is the relevent PSR-3 documentation.

    /**
     * Critical conditions.
     *
     * Example: Application component unavailable, unexpected exception.
     *
     * @param string $message
     * @param array $context
     * @return void
     */
    public function critical($message, array $context = array());

    /**
     * Runtime errors that do not require immediate action but should typically
     * be logged and monitored.
     *
     * @param string $message
     * @param array $context
     * @return void
     */
    public function error($message, array $context = array());

Unexpected exceptions should logged at LogLevel::CRITICAL, not at LogLevel::ERROR.

jderusse added a commit that referenced this issue Jan 28, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants