Getting the logger working in Doctrine MongoDB ODM?
Asked Answered
V

1

6

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?

Vikiviking answered 5/7, 2011 at 15:21 Comment(0)
V
6

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);
Vikiviking answered 5/7, 2011 at 23:39 Comment(1)
ty. Today is 2014, but this issue still exists :(Attentive

© 2022 - 2024 — McMap. All rights reserved.