Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (47.6k 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 (106k 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()

Related questions

0 votes
2 answers
asked Oct 18, 2019 in Web Technology by Sammy (47.6k points)
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...