0 votes
1 view
in SQL by (30.9k points)

The question is as basic as it is simple... How do you log all queries in a "tail"able log file in MongoDB?

I have tried:

  • setting the profiling level

  • setting the slow ms parameter starting

  • mongod with the -vv option

The /var/log/mongodb/mongodb.log keeps showing just the current number of active connections. 

1 Answer

0 votes
by (73.5k points)

You can log all queries using the following queries:-

$ mongo 

MongoDB shell version: 2.4.9 

connecting to: test 

> use myDb 

switched to db myDb 

> db.getProfilingLevel()

 0 

> db.setProfilingLevel(2) 

{ "was" : 0, "slowms" : 1, "ok" : 1 }

 > db.getProfilingLevel() 

> db.system.profile.find().pretty()

...