Rails 应用程序中 Mongoid 记录器的未定义方法“level”
我看到这个:
undefined method `level' for #<Mongoid::Logger:0xcd1a1f>
当我在 init.xml 中设置 Mongoid 记录器时。记录器是通过简单的方式设置的:
Mongoid.logger = Logger.new($stdout)
在 global.rb
这里有什么问题?如何让 Mongoid 登录到我自己的记录器以便我可以看到一些查询?
我也尝试过没有效果:
Mongoid.logger = Logger.new($stdout, :info)
I'm seeing this:
undefined method `level' for #<Mongoid::Logger:0xcd1a1f>
When I set the Mongoid logger in my init. The logger is being set by trivial means:
Mongoid.logger = Logger.new($stdout)
in global.rb
What is the issue here? How do I get Mongoid to log to my own logger so I can see some queries?
I've also tried to not avail:
Mongoid.logger = Logger.new($stdout, :info)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最新版本已损坏:
https://github.com/mongoid/mongoid
http://travis-ci.org/#!/mongoid/mongoid/builds /722676
您将不得不等到他们修复它或使用旧版本
编辑:好吧,我遇到了同样的问题,我通过这样做解决了它:
1)设置您想要的特定版本Gemfile 中的 mongoid gem
2) 安装
3) 重新启动服务器
The latest build is broken:
https://github.com/mongoid/mongoid
http://travis-ci.org/#!/mongoid/mongoid/builds/722676
You will have to wait till they fix it or use an older version
Edit: Ok I was having the same problem and I solved it by doing this:
1) Set the specific version you want for mongoid gem in your Gemfile
2) install
3) restart your server
我认为这里的问题可能是您启动
Mongoid.logger
的位置以及您的操作方式。在我的使用Mongoid 2.4.3
运行Ruby 1.9.2
的Rails 3.2
应用程序中,实例化Mongoid Logger
没有问题>。您可以在此处阅读 Mongoid 配置,其中显示了如何设置记录器。
我最近的应用程序中用于在
/config
文件夹中找到的Application.rb
中实例化记录器的代码I think the issue here may be where you are initiating the
Mongoid.logger
and how you are doing it. In myRails 3.2
app runningRuby 1.9.2
withMongoid 2.4.3
I have no problem instantiating theMongoid Logger
.Here you can read the Mongoid Configuration that shows how to setup the logger.
The code from my most recent app to instantiate the logger in
Application.rb
found in the/config
folder