Shell logging for mongodb

841 Views Asked by At

I am new to mongodb and trying to figure out a lot.

Can we configure shell logging for mongodb? What I mean is the capability to get logs from the Shell to track queries for auditing purposes for version 4?

If so - what commands do we have to run please?

Thank you for your help

1

There are 1 best solutions below

1
prasad_ On

There are two versions of MongoDB shell: the newer mongosh and the older/legacy mongo shell.

mongo maintains a history of commands in the .dbshell file. For example, in the Windows 7 environment this can be found at the folder: C:\Users\<user_name>

MongoDB Shell mongosh stores logs for each session and can be retrieved as explained at: Retrieve Shell Logs. For example, in Windows environment this can be found at the folder: C:\Users\<user_name>\AppData\Local\. The log files are of the format <LogID>_log.