-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Make the log level of match route log configurable #14747
Comments
Just change the injected logger. You can for example use a custom decorator that changes |
Some lines of sample code would be appreciated |
I know this issue is closed and a few years old, but I was looking to accomplish this and thought I would share my solution (application is using framework-bundle 4.4). You can find the default router_listener service ( symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml Lines 108 to 117 in 3619661
To override, I converted this definition to YAML and added it to my application's services:
# Override router_listener service defined in vendor/symfony/framework-bundle/Resources/config/routing.xml
# to suppress logger (definition below is identical except for passing in null for the logger)
router_listener:
class: Symfony\Component\HttpKernel\EventListener\RouterListener
arguments:
- '@router'
- '@request_stack'
- '@?router.request_context'
- null
- '%kernel.project_dir%'
- '%kernel.debug%' This definition is identical, except that Also, using named arguments might be better/clearer, but my goal was to match the XML configuration as close as possible. |
Here's my solution: use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class RouterListenerLoggingSilencerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
$definition = $container->getDefinition('router_listener');
foreach ($definition->getArguments() as $index => $argument) {
if ('logger' != $argument) {
continue;
}
$definition->replaceArgument($index, null);
}
}
} |
I think it would be fine if we can set the "Matched route..." log level to DEBUG.
On some projects, INFO may not be the accurate level for this information.
The text was updated successfully, but these errors were encountered: