1

How to view all queries in console to mongodb?

Mongoid.logger = Logger.new($stdout)

does not help

database.rb

host = 'localhost'
port = Mongo::Connection::DEFAULT_PORT
database_name = case Padrino.env
  when :development then 'blog_development'
  when :production  then 'blog_production'
  when :test        then 'blog_test'
end
Mongoid.logger = Logger.new($stdout)
Mongoid.database = Mongo::Connection.new(host, port).db(database_name)
amirka
  • 313
  • 2
  • 12
  • For future visitors, if you want beautiful colored logging similar to active record, you might want to look at [the mongo beautiful logger gem](https://github.com/redline-gh/mongo_beautiful_logger/) – Ibraheem Ahmed Jul 12 '20 at 23:42

1 Answers1

1

Try with this: Mongoid.logger = Padrino.logger

Or better:

Mongo::Connection.new(host, 27017, :logger => Padrino.logger).db(name)
DAddYE
  • 1,719
  • 11
  • 16
  • mmm are you sure that this is the only necessary thing to configure logging in mongoid? Using same way in mongomapper works like a charm. – DAddYE Nov 23 '11 at 08:22