Navigation

mongocli atlas logs download

On this page

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.

Syntax

mongocli atlas logs|log download <hostname> <log-name>
     [ --start <start-date> ]
     [ --end <end-date> ]
     [ --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.

Options

Option Type Description Required?
<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

The name of the log file to retrieve. Valid values are:

Note

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

yes
--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
--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
--out, -o string Output filename or path to filename. If omitted, logs are downloaded to your current directory as <log-name>.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 that contains the cluster to update. If omitted, uses the project ID in the profile or environment variable. no

Output

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.

Examples

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.