Discussion:
How do I log every query in my test instance?
kellypw
2013-01-09 18:57:29 UTC
Permalink
Running 2.0.6 on Windows 7. I have my service created with this config:

logpath=C:\mongodb\logs\mongodb.log
logappend=true
dbpath=C:\data\db
profile=2
slowms=0
rest=true
diaglog=3

Unfortunately, this is still not logging every query to my mongodb.log.
This is my local test environment and I'd like to track every single read
and write to confirm my queries are constructed properly. I see only a few
queries that actually get logged. I assumed that slowms=0 would track
everything - is that incorrect? Any help is appreciated.
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
Jeff Lee
2013-01-09 19:15:33 UTC
Permalink
Hey Kelly,

If you want to see all queries you can either:

1. Set profiling<http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/>to
2 and then check the system.profile collection

2. Use mongosniff <http://docs.mongodb.org/manual/reference/mongosniff/> (
not sure that's available on windows though )

Hope that helps.
Post by kellypw
logpath=C:\mongodb\logs\mongodb.log
logappend=true
dbpath=C:\data\db
profile=2
slowms=0
rest=true
diaglog=3
Unfortunately, this is still not logging every query to my mongodb.log.
This is my local test environment and I'd like to track every single read
and write to confirm my queries are constructed properly. I see only a few
queries that actually get logged. I assumed that slowms=0 would track
everything - is that incorrect? Any help is appreciated.
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
kellypw
2013-01-09 19:27:13 UTC
Permalink
Thanks i'll see if mongosniff is available on Windows. Profiler is set to
2 across the instance on startup already -
Post by Jeff Lee
Hey Kelly,
1. Set profiling<http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/>to 2 and then check the system.profile collection
2. Use mongosniff <http://docs.mongodb.org/manual/reference/mongosniff/> (
not sure that's available on windows though )
Hope that helps.
Post by kellypw
logpath=C:\mongodb\logs\mongodb.log
logappend=true
dbpath=C:\data\db
profile=2
slowms=0
rest=true
diaglog=3
Unfortunately, this is still not logging every query to my mongodb.log.
This is my local test environment and I'd like to track every single read
and write to confirm my queries are constructed properly. I see only a few
queries that actually get logged. I assumed that slowms=0 would track
everything - is that incorrect? Any help is appreciated.
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
Jeff Lee
2013-01-09 19:44:02 UTC
Permalink
Kelly,

If you're setting profiling you'll want to check the system.profile
collection for the queries not the logfile. You'll also want to verify that
the collection is actually created - I believe there were some bugs when
setting that in the conf file.

I also usually just enable it from the shell:

e.g.

use test
db.setProfilingLevel(2)
db.system.profile.find()
db.setProfilingLevel(0)
Post by kellypw
Thanks i'll see if mongosniff is available on Windows. Profiler is set to
2 across the instance on startup already -
Post by Jeff Lee
Hey Kelly,
1. Set profiling<http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/>to 2 and then check the system.profile collection
2. Use mongosniff <http://docs.mongodb.org/manual/reference/mongosniff/> (
not sure that's available on windows though )
Hope that helps.
logpath=C:\mongodb\logs\**mongodb.log
logappend=true
dbpath=C:\data\db
profile=2
slowms=0
rest=true
diaglog=3
Unfortunately, this is still not logging every query to my mongodb.log.
This is my local test environment and I'd like to track every single read
and write to confirm my queries are constructed properly. I see only a few
queries that actually get logged. I assumed that slowms=0 would track
everything - is that incorrect? Any help is appreciated.
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
kellypw
2013-01-09 19:48:43 UTC
Permalink
Yeah... so I checked profiler entries by doing 'show profile' and only a
handful of the queries seem to be logged. I'm testing this via my
application - java/xml and i actually get the results from my call, i just
want to confirm exactly how the query is getting generated. So I know that
the collection is correct and am getting results back, but it's only
logging the query in the log file occasionally (seemingly randomly).

Even queries I do via the js shell - only some get logged. It's very
odd... I assumed it was something in my settings not triggering (such as
the slowms value? perhaps 0 is not a valid value?), but I had the same
issue when I set it to 1....

I''ll keep playing around - thanks!
Post by Jeff Lee
Kelly,
If you're setting profiling you'll want to check the system.profile
collection for the queries not the logfile. You'll also want to verify that
the collection is actually created - I believe there were some bugs when
setting that in the conf file.
e.g.
use test
db.setProfilingLevel(2)
db.system.profile.find()
db.setProfilingLevel(0)
Post by kellypw
Thanks i'll see if mongosniff is available on Windows. Profiler is set
to 2 across the instance on startup already -
Post by Jeff Lee
Hey Kelly,
1. Set profiling<http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/>to 2 and then check the system.profile collection
2. Use mongosniff <http://docs.mongodb.org/manual/reference/mongosniff/> (
not sure that's available on windows though )
Hope that helps.
logpath=C:\mongodb\logs\**mongodb.log
logappend=true
dbpath=C:\data\db
profile=2
slowms=0
rest=true
diaglog=3
Unfortunately, this is still not logging every query to my
mongodb.log. This is my local test environment and I'd like to track every
single read and write to confirm my queries are constructed properly. I
see only a few queries that actually get logged. I assumed that slowms=0
would track everything - is that incorrect? Any help is appreciated.
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
kellypw
2013-01-09 19:53:12 UTC
Permalink
Ah yes db.system.profile.find() does indeed show them all. I'll have to
figure out a way to effectively parse those - but at least they are there.
Thanks!
Post by Jeff Lee
Kelly,
If you're setting profiling you'll want to check the system.profile
collection for the queries not the logfile. You'll also want to verify that
the collection is actually created - I believe there were some bugs when
setting that in the conf file.
e.g.
use test
db.setProfilingLevel(2)
db.system.profile.find()
db.setProfilingLevel(0)
Post by kellypw
Thanks i'll see if mongosniff is available on Windows. Profiler is set
to 2 across the instance on startup already -
Post by Jeff Lee
Hey Kelly,
1. Set profiling<http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/>to 2 and then check the system.profile collection
2. Use mongosniff <http://docs.mongodb.org/manual/reference/mongosniff/> (
not sure that's available on windows though )
Hope that helps.
logpath=C:\mongodb\logs\**mongodb.log
logappend=true
dbpath=C:\data\db
profile=2
slowms=0
rest=true
diaglog=3
Unfortunately, this is still not logging every query to my
mongodb.log. This is my local test environment and I'd like to track every
single read and write to confirm my queries are constructed properly. I
see only a few queries that actually get logged. I assumed that slowms=0
would track everything - is that incorrect? Any help is appreciated.
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
Jeff Lee
2013-01-09 19:55:33 UTC
Permalink
Glad the works.

btw the reason show profile may not haver returned them is because it's
shell helper that only shows the 5 most recent operations >= 1ms.

http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/

Regards
Post by kellypw
Ah yes db.system.profile.find() does indeed show them all. I'll have to
figure out a way to effectively parse those - but at least they are there.
Thanks!
Post by Jeff Lee
Kelly,
If you're setting profiling you'll want to check the system.profile
collection for the queries not the logfile. You'll also want to verify that
the collection is actually created - I believe there were some bugs when
setting that in the conf file.
e.g.
use test
db.setProfilingLevel(2)
db.system.profile.find()
db.setProfilingLevel(0)
Post by kellypw
Thanks i'll see if mongosniff is available on Windows. Profiler is set
to 2 across the instance on startup already -
Post by Jeff Lee
Hey Kelly,
1. Set profiling<http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/>to 2 and then check the system.profile collection
2. Use mongosniff<http://docs.mongodb.org/manual/reference/mongosniff/> (
not sure that's available on windows though )
Hope that helps.
logpath=C:\mongodb\logs\**mongod**b.log
logappend=true
dbpath=C:\data\db
profile=2
slowms=0
rest=true
diaglog=3
Unfortunately, this is still not logging every query to my
mongodb.log. This is my local test environment and I'd like to track every
single read and write to confirm my queries are constructed properly. I
see only a few queries that actually get logged. I assumed that slowms=0
would track everything - is that incorrect? Any help is appreciated.
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
kellypw
2013-01-09 20:02:05 UTC
Permalink
Thanks - also found :

db.system.profile.find().limit(10).sort( { ts : -1 } ).pretty()

To limit and present purtified results - so already done just needed a little digging.

Thanks for your help....
Post by Jeff Lee
Glad the works.
btw the reason show profile may not haver returned them is because it's
shell helper that only shows the 5 most recent operations >= 1ms.
http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/
Regards
Post by kellypw
Ah yes db.system.profile.find() does indeed show them all. I'll have to
figure out a way to effectively parse those - but at least they are there.
Thanks!
Post by Jeff Lee
Kelly,
If you're setting profiling you'll want to check the system.profile
collection for the queries not the logfile. You'll also want to verify that
the collection is actually created - I believe there were some bugs when
setting that in the conf file.
e.g.
use test
db.setProfilingLevel(2)
db.system.profile.find()
db.setProfilingLevel(0)
Post by kellypw
Thanks i'll see if mongosniff is available on Windows. Profiler is set
to 2 across the instance on startup already -
Post by Jeff Lee
Hey Kelly,
1. Set profiling<http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/>to 2 and then check the system.profile collection
2. Use mongosniff<http://docs.mongodb.org/manual/reference/mongosniff/> (
not sure that's available on windows though )
Hope that helps.
logpath=C:\mongodb\logs\**mongod**b.log
logappend=true
dbpath=C:\data\db
profile=2
slowms=0
rest=true
diaglog=3
Unfortunately, this is still not logging every query to my
mongodb.log. This is my local test environment and I'd like to track every
single read and write to confirm my queries are constructed properly. I
see only a few queries that actually get logged. I assumed that slowms=0
would track everything - is that incorrect? Any help is appreciated.
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To unsubscribe from this group, send email to
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
Continue reading on narkive:
Loading...