Rails 应用程序中 Mongoid 记录器的未定义方法“level”

发布于 2025-01-08 03:25:49 字数 379 浏览 2 评论 0原文

我看到这个:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无远思近则忧 2025-01-15 03:25:49

最新版本已损坏:

https://github.com/mongoid/mongoid
http://travis-ci.org/#!/mongoid/mongoid/builds /722676

您将不得不等到他们修复它或使用旧版本

编辑:好吧,我遇到了同样的问题,我通过这样做解决了它:

1)设置您想要的特定版本Gemfile 中的 mongoid gem

gem 'mongoid', '= 2.4.5'

2) 安装

$ bundle install

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

gem 'mongoid', '= 2.4.5'

2) install

$ bundle install

3) restart your server

淡水深流 2025-01-15 03:25:49

我认为这里的问题可能是您启动 Mongoid.logger 的位置以及您的操作方式。在我的使用 Mongoid 2.4.3 运行 Ruby 1.9.2Rails 3.2 应用程序中,实例化 Mongoid Logger 没有问题>。

您可以在此处阅读 Mongoid 配置,其中显示了如何设置记录器。

我最近的应用程序中用于在 /config 文件夹中找到的 Application.rb 中实例化记录器的代码

module Application_Name
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    config.mongoid.logger = Logger.new($stdout)

I think the issue here may be where you are initiating the Mongoid.logger and how you are doing it. In my Rails 3.2 app running Ruby 1.9.2 with Mongoid 2.4.3 I have no problem instantiating the Mongoid 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

module Application_Name
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    config.mongoid.logger = Logger.new($stdout)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文