0 votes
1 view
in SQL by (47.8k 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 (107k 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.8k points)
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...