Docs Menu
Docs Home
/
MongoDB Shell
/ /

View Shell Logs

On this page

  • Find your Log ID.
  • View the log for the session.

The MongoDB Shell stores logs for each session. The default log location depends on your operating system.

1

Example

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: 2.4.0
2

MongoDB Shell saves the log for each session to your user's .mongodb/mongosh directory:

~/.mongodb/mongosh/<LogID>_log

Run the following command to view the log for a session:

cat ~/.mongodb/mongosh/<LogID>_log

Run the following command to tail the log for a session:

tail -f ~/.mongodb/mongosh/<LogID>_log

MongoDB Shell saves the log for each session to your user's C:\Users\<username>\AppData\Local\ directory:

%UserProfile%/AppData/Local/mongodb/mongosh/<LogID>_log

Run the following PowerShell command to view the log for a session:

Get-Content %UserProfile%/AppData/Local/mongodb/mongosh/<LogID>_log

Run the following PowerShell command to tail the log for a session:

Get-Content %UserProfile%/AppData/Local/mongodb/mongosh/<LogID>_log

Tip

To change where MongoDB Shell writes logs, see Specify Log File Location.

Back

Logs