I've successfully integrated Doctrine MongoDB module in Zend Framework 2 and now I need to keep track of each query to MongoDB. Does anybody know how to turn on logging?
Asked
Active
Viewed 1,136 times
0
-
Are you asking [how to turn on the db profiler](http://stackoverflow.com/questions/2894077/how-to-enable-sql-output-to-log-file-with-zend-db)? – AD7six Oct 26 '12 at 16:44
2 Answers
0
You can log each query using the MongoDB Database Profiler. Use profile level 2. All queries will be logged to the system.profile
collection.

slee
- 524
- 2
- 6
-
thank's a lot for your answer. But it would be better if I can print all queries directly on current web page or something like this. – Pavel Oct 26 '12 at 12:56
-
That's sort of true; you're requesting functionality that seems very MongoDB specific and maybe outside the scope of Doctrine, an object mapper. – slee Oct 26 '12 at 18:47
0
I just proposed a pull request on the DoctrineMongoODMModule to integrate the logging configuration option of MongoDB ODM. Hopefully it'll be merged soon.
You will then only have to add this in the doctrine-mongo-odm.global.php
file :
'doctrine' => array(
// [...]
'configuration' => array(
'odm_default' => array(
// [...]
'logger_callable' => function(array $log, \Zend\ServiceManager\ServiceLocatorInterface $sl) {
print_r($log);
}
)
)
)
The logger_callable will be called for everything there is to log.

jhuet
- 396
- 2
- 11