让记录器在 Doctrine MongoDB ODM 中工作?
我正在尝试让记录器在 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);
这是参考: http://www.doctrine-project .org/docs/mongodb_odm/1.0/en/reference/logging.html
我正在使用文档管理器的查询生成器查询文档。我正在成功查找并保留文档。但记录器回调永远不会被调用。我可能做错了什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过#doctrine IRC 频道找到了解决方案。连接需要单独传递配置,因为 DocumentManager 不会将传递给它的配置应用于它创建的连接。这将在未来版本中修复。下面是你如何做的 -
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 -