Logging queries in a development environment

4,098 views
Skip to first unread message

richardhenry

unread,
Jun 24, 2010, 11:54:54 AM6/24/10
to mongodb-user
Is it possible to have MongoDB log the queries executed on it? (Either
to stdout or to a log file.) I'd like to see a log of the queries that
my application is executing as it runs during testing.

Richard

Kristina Chodorow

unread,
Jun 24, 2010, 1:07:57 PM6/24/10
to mongod...@googlegroups.com
You could run ./mongod -vv (or more... ./mongod -vvvvv) and it will show you query info:

Thu Jun 24 13:06:27 query: test.collection{ x: 1.0, y: 2.0 }

Very long queries are truncated, though.


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


John Nunemaker

unread,
Jun 24, 2010, 2:44:25 PM6/24/10
to mongod...@googlegroups.com
On OSX you can do this:

sudo mongosniff —source NET l0

Not sure if it is same/different on other OS's. Also, I know in Ruby you can just pass a logger to the connection, but I am not sure about other drivers.

Michael Dirolf

unread,
Jun 24, 2010, 6:01:52 PM6/24/10
to mongod...@googlegroups.com
Check out the database profiler. Can log all queries, or just slow ones:
http://www.mongodb.org/display/DOCS/Database+Profiler

Reply all
Reply to author
Forward
0 new messages