monolog-bundle: `excluded_404s` does not work for symfony 3
The generated NotFoundActivationStrategy service in a service locator looks like:
protected function getMonolog_Handler_Errors_NotFoundStrategyService()
{
$this->services['monolog.handler.errors.not_found_strategy'] = $instance = new \Symfony\Bundle\MonologBundle\NotFoundActivationStrategy(array(0 => '^/'), 400);
$instance->setRequest(NULL);
return $instance;
}
So the request is never passed into the object and it does not take the passed url regexes into account.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22 (11 by maintainers)
@zerkms Thanks a million. This led me in the right direction.
If anybody stumbles over this, here is how I solved it for us: The implementation of NotFoundActivationStrategy in monolog-bridge uses RequestStack and was added as part of Symfony 2.6.
So I added a service definition for this class.
First parameter is the RequestStack, second parameter are the “excluded_404s” or blacklist, third parameter is the action_level, when the fingers_crossed handler is activated (we use ERROR in this case but it defaults to WARNING in monolog-bundle).
Then I added this service as the activation_strategy parameter in my monolog config:
Important: I had to remove the “excluded_404s” parameter, because it is not allowed in combination with a custom activation_strategy.
Hope this helps someone.
to hell maybe? 😄 (scnr)
Is there any plan to include a solution for this in an upcoming release? We are using the fingers crossed handler to get notified via hipchat when one of our system throws an Exception. Since moving to Symfony 3 we are bombarded with 404 notifications from bots trying to access wp_admin.php admin.php etc. which renders the notifications almost useless.
Is there any other way to mitigate this?
@Laurent3170
I believe
would work
@Laurent3170 I think this depends on how much pain you are feeling right now 😄 . For us it was just way too much noise so I implemented it and never looked back. In case if something more “official” arrives, it would not be to much work to revert.
This is related to https://github.com/symfony/monolog-bundle/pull/94