Reputation: 34
Is there a way to disable Doctrine MongoDB bundle logger on fixture load only? like suggested in https://stackoverflow.com/a/35222045/3965970 but for MongoDB bundle.
Thanks
Upvotes: 0
Views: 1004
Reputation: 1536
Unfortunately in Doctrine MongoODM-bundle version 4.0 and higher this approach no longer works.
The easiest way is to disable logging in the configuration, see https://symfony.com/doc/master/bundles/DoctrineMongoDBBundle/config.html
You can also disable the logger manually, but you'll need doctrine_mongodb.odm.command_logger
service.
What I did in my Symfony 4 application is to create an alias to enable proper dependency injection and then unregister the listener:
services.yaml
Doctrine\Bundle\MongoDBBundle\APM\PSRCommandLogger:
alias: "doctrine_mongodb.odm.command_logger"
some constructor of a Command or Service:
public function __construct(PSRCommandLogger $mongoLogger)
{
$mongoLogger->unregister();
}
Upvotes: 0
Reputation: 1055
Yes, absolutely the same way, call
$manager->getConnection()->getConfiguration()->setLoggerCallable(null);
right in the fixture.
Upvotes: 0