Retrieve Shell Logs¶
The MongoDB Shell (
mongosh) is currently available as a Beta
release. The product, its features, and the corresponding
documentation may change during the Beta stage.
You can view or tail the logs for a MongoDB Shell session based on its log ID.
View MongoDB Shell Logs¶
Find your Log ID.¶
MongoDB Shell displays the log ID each time you open the shell.
$ mongosh Current Mongosh Log ID: c2961dbd6b73b052671d9df0 Connecting to: mongodb://127.0.0.1:27017 Using MongoDB: 4.2.8 Using Mongosh Beta: 0.8.2
View the log for the session.¶
MongoDB Shell saves the log for each session to your user's
Run the following command to view the log for a session:
Run the following command to tail the log for a session:
tail -f ~/.mongodb/mongosh/<LogID>_log
View MongoDB Shell Command History¶
MongoDB Shell saves a history of all commands you've run across sessions. When a new command is issued, it is added to the beginning of the history file.
Open the following file in a text editor to view the MongoDB Shell command history:
|Operating System||Path to History File|
|macOS and Linux|