Docs Menu
Docs Home
/ /
MongoDB Command Line Interface
/ / /

mongocli atlas logs download

On this page

  • Syntax
  • Options
  • Output
  • Examples

The logs download command downloads the logs for a specified Atlas host to a .gz file. You can also download logs through the Atlas UI or API.

mongocli atlas logs|log download <hostname> <log-name>
[ --start <start-date> ]
[ --end <end-date> ]
[ --force ]
[ --out <file-destination>]
[ --profile|-P <profile-name> ]
[ --projectId <id-of-project> ]

Note

Use -h or --help to view the command-line help for this command.

Option
Type
Description
Required?
--end
string
Timestamp in the number of seconds that have elapsed since the UNIX epoch that specifies the end point for the range of log messages to retrieve. Default is current timestamp.
no
--force
Overwrites an existing log file of the same name, if present.
no
<hostname>
string

Name of the MongoDB host for which to download logs.

To find the hostnames for a Atlas project, you can use the process list mongocli command. You can also find hostnames through the Atlas API or UI Overview tab for a cluster.

yes
<log-name>
string

Name of the log file to retrieve. Valid values are:

  • mongodb.gz

  • mongos.gz

  • mongodb-audit-log.gz

  • mongos-audit-log.gz

Note

Audit logs are only available if you have enabled Database Auditing for an Atlas project.

yes
--out
string

Output filename, path to filename, or standard output. The filename must be in the following format:

<file-name>.<extension>.gz

For standard output, value must be /dev/stdout. The command returns the output in compressed format, which you can decompress using an appropriate tool for you OS.

If omitted, MongoDB CLI downloads logs to your current directory as <log-name>.log.gz.

no
--profile, -P
string
Name of the profile where the public and private keys for the project are saved. If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI.
no
--projectId
string

Unique identifier of the project. If omitted, uses the project ID in the profile or environment variable.

no
--start
string
Timestamp in the number of seconds that have elapsed since the UNIX epoch that specifies starting point for the range of log messages to retrieve. Default is 24 hours prior to the current timestamp.
no

The command downloads the logs of the specified <hostname> to:

  • The current directory as a file named <log-name>.gz, or

  • A directory and filename you specify with the --out option.

If the command returns errors, see Troubleshooting for recommended solutions.

The following example uses the mongocli atlas logs download command to download the mongodb logs from host atlas-123abc-shard-00-00.111xx.mongodb.net. It uses the default profile to access the project.

mongocli atlas logs download atlas-123abc-shard-00-00.111xx.mongodb.net mongodb.gz

The previous command downloads the log file mongodb.gz to the current directory.

The following command uses gunzip to decompress the output.

mongocli atlas logs download atlas-123abc-shard-00-00.111xx.mongodb.net mongodb.gz --out /dev/stdout --force | gunzip

The previous command prints log entries similar to the following to the terminal.

2020-11-06T17:16:45.801+0000 I INDEX [initandlisten] index build: done building index _id_ on ns local.startup_log
2020-11-06T17:16:45.801+0000 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
...

Back

Logs