I'm trying to get the logger working in the Doctrine ODM.
// .. some initialization code here ...
$mongoConfig->setLoggerCallable(function(array $log){
print_r($log);
die("Mongo Logging Called...");
});
$dm = \Doctrine\ODM\MongoDB\DocumentManager::create(new \Doctrine\MongoDB\Connection(), $mongoConfig);
Here's the reference: http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/logging.html
I'm querying Documents using the query builder of the document manager.. I'm being to successfully find and persist documents. But the logger call back is NEVER called. What could I be doing wrong?
Found the solution through the #doctrine IRC channel. The connection needs to be passed the configuration separately as the DocumentManager does not apply the configuration passed on to it to the connection it creates. This will be fixed in a future version. Here's how you do it instead -
// setup the mongodb connection
$connection = new \Doctrine\MongoDB\Connection(null, array(), $mongoConfig);
// create the document manager for the connection above
$dm = \Doctrine\ODM\MongoDB\DocumentManager::create($connection, $mongoConfig);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With