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

Duplicated log during an error #73

Closed
shavounet opened this issue Aug 31, 2022 · 2 comments
Closed

Duplicated log during an error #73

shavounet opened this issue Aug 31, 2022 · 2 comments

Comments

@shavounet
Copy link
Contributor

shavounet commented Aug 31, 2022

Description

In our project we noticed that when an error occurs, we have 2 logs

  • one with the route and a complete error message
  • one with less data (mostly useless, all data is already in the 1st)

With some analysis, I found that the fos/rest-bundle that is installed, have an event listener on kernel.exception that create a new response (thank to this Symfony component) that triggers a second time kernel.response.

[2022-08-31 17:27:31] event.DEBUG: Notified event "kernel.response" to listener "M6Web\Bundle\LogBridgeBundle\EventDispatcher\LogRequestListener::onKernelTerminate".
[2022-08-31 17:27:31] event.DEBUG: Notified event "kernel.exception" to listener "M6Web\Bundle\LogBridgeBundle\EventDispatcher\LogExceptionListener::onKernelException".
[2022-08-31 17:27:31] event.DEBUG: Notified event "kernel.exception" to listener "FOS\RestBundle\EventListener\ExceptionListener::onKernelException".
[2022-08-31 17:27:31] event.DEBUG: Listener "FOS\RestBundle\EventListener\ExceptionListener::onKernelException" stopped propagation of the event "kernel.exception".
[2022-08-31 17:27:31] event.DEBUG: Notified event "kernel.response" to listener "M6Web\Bundle\LogBridgeBundle\EventDispatcher\LogRequestListener::onKernelTerminate".

This is not exclusive to the FOS Rest Bundle, kernel.response can be triggered every time a response is calculated.

A proposed solution would be to change the listener to properly listen on kernel.terminate, which is only triggered once.
What do you think ?

@valentin-claras
Copy link
Contributor

Well, it's not the same log, but I agree one seems useless.
Imho, we need to think about what we want. I would say that we want to log the final response, so terminate could be great if we have access to the response with it's response code.

@shavounet
Copy link
Contributor Author

Resolved thanks to #74 and #75

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

No branches or pull requests

2 participants