-
We're using Symfony/4.4 (to be upgraded later this year). Invalid URL requests end up in our logs as uncaught exceptions (and also submitted to Sentry):
It's fine to have them logged so we can investigate, but they're almost never an error on our side and we're afraid they can mask actual errors. I've found two ways to have a custom log entry (event subscriber and listener both work for that) but I still get the default uncaught exception entry. The only way to avoid that is to craft a response in the subscriber/listener, but that means losing the default Twig template. What are my options handle this? Namely:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
You can configure monolog to ignore all 404. https://symfony.com/doc/current/logging/monolog_exclude_http_codes.html |
Beta Was this translation helpful? Give feedback.
-
Another option is to configure the log level for each exception |
Beta Was this translation helpful? Give feedback.
-
I've given up on the template (after all, it's the default Symfony one so I'm sure nobody in Business asked for it) and just generated a response in the subscriber to let Symfony know I handled it myself: $response = new Response('404 Not Found', headers: ['Content-Type' => 'text/plain']);
$event->setResponse($response); Per exception log level requires 5.4 so I'll have a look once we're able to upgrade. |
Beta Was this translation helpful? Give feedback.
I've given up on the template (after all, it's the default Symfony one so I'm sure nobody in Business asked for it) and just generated a response in the subscriber to let Symfony know I handled it myself:
Per exception log level requires 5.4 so I'll have a look once we're able to upgrade.