> ## Documentation Index
> Fetch the complete documentation index at: https://www.aptible.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# aptible logs_from_archive

This command is used to retrieve container logs from your own [Disaster Log Archive](https://www.aptible.com/docs/core-concepts/observability/logs/s3-log-archives.md).

> [!WARNING]
>
> You must have enabled log archiving for your Dedicated Stack(s) in order to use this command.

# Synopsis

```
Usage:
  aptible logs_from_archive [flags]

Flags:
      --app-id int                    App ID to download logs for
      --bucket string                 S3 bucket name (required)
      --container-id string           Container ID prefix (at least 12 characters)
      --database-id int               Database ID to download logs for
      --decryption-keys stringArray   Aptible-provided Base64 decryption keys
      --download-location string      Local path to download and decrypt log files
      --end-date string               Include logs up to this UTC date (YYYY-MM-DD)
      --endpoint-id int               Endpoint ID to download logs for
      --region string                 AWS region of the S3 bucket (required)
      --stack string                  Aptible stack name (required)
      --start-date string             Include logs starting from this UTC date (YYYY-MM-DD)
      --string-matches stringArray    Strings to match in log file paths
```

> [!NOTE]
>
> You can find resource ID's by looking at the URL of a resource on the Aptible Dashboard, or by using the [JSON output format](https://www.aptible.com/docs/reference/aptible-cli/cli-commands/overview#output-format) for the [`aptible db:list`](https://www.aptible.com/docs/reference/aptible-cli/cli-commands/cli-db-list) or [`aptible apps`](https://www.aptible.com/docs/reference/aptible-cli/cli-commands/cli-apps) commands.

> This command also allows retrieval of logs from deleted resources. Please contact [Aptible Support](https://www.aptible.com/docs/how-to-guides/troubleshooting/aptible-support.md) for assistance identifying the proper resource IDs of deleted resources.

# Examples

## Search for all archived logs for a specific Database

By default, no logs are downloaded. Matching file names are printed on the screen.

```shell theme={null}
aptible logs_from_archive --database-id "$ID" \
        --stack "$STACK" \
        --region "$REGION" \
        --decryption-keys "$KEY"
```

## Search for archived logs for a specific Database within a specific date range

You can specify a date range in UTC to limit the search to logs emitted during a time period.

```shell theme={null}
aptible logs_from_archive --database-id "$ID" --start-date "2022-08-30" --end-date "2022-10-03" \
        --stack "$STACK" \
        --region "$REGION" \
        --decryption-keys "$KEY"
```

## Download logs from a specific App to a local path

Once you have identified the files you wish to download, add the `--download-location` parameter to download the files to your local system.

> [!WARNING]
>
> Warning: Since container logs may include PHI or sensitive credentials, please choose the download location carefully.

```shell theme={null}
aptible logs_from_archive --app-id "$ID" --download-location "$LOCAL_PATH" \
        --stack "$STACK" \
        --region "$REGION" \
        --decryption-keys "$KEY"
```

## Search for logs from a specific Container

You can search for logs for a specific container if you know the container ID.

```shell theme={null}
aptible logs_from_archive --container-id "$ID" \
        --stack "$STACK" \
        --region "$REGION" \
        --decryption-keys "$KEY"
```
