# Logging

This document provides instructions to manage [<mark style="color:blue;">Logging</mark>](https://docs.ionos.com/sections-test/guides/storage-and-backup/ionos-object-storage/settings/logging) using the CLI. Additionally, these tasks can also be performed using the [<mark style="color:blue;">DCD</mark>](https://docs.ionos.com/sections-test/guides/storage-and-backup/settings/logging#dcd) and [<mark style="color:blue;">API</mark>](https://api.ionos.com/docs/s3/v2/#tag/Logging).

{% hint style="info" %}
**Prerequisites:**

* Set up the AWS CLI by following the [<mark style="color:blue;">installation instructions</mark>](https://docs.ionos.com/sections-test/guides/storage-and-backup/ionos-object-storage/s3-tools/awscli/awscli-configure).
* Make sure to consider the supported [<mark style="color:blue;">Endpoints</mark>](https://docs.ionos.com/sections-test/guides/storage-and-backup/ionos-object-storage/endpoints).
  {% endhint %}

## Commands

{% hint style="info" %}
**Prerequisite:** Grant permissions to the Log Delivery Group to the bucket where logs will be stored. We recommend using a separate bucket for logs, but it must be in the same region. Log Delivery Group must be able to write objects and read ACL.
{% endhint %}

```bash
aws s3api put-bucket-acl \
    --bucket MY-BUCKET-FOR-LOGS \
    --grant-write URI=http://acs.amazonaws.com/groups/s3/LogDelivery \
    --grant-read-acp URI=http://acs.amazonaws.com/groups/s3/LogDelivery \
    --endpoint-url https://s3.eu-central-2.ionoscloud.com
```

After that, you can enable Logging for a bucket:

```bash
aws s3api put-bucket-logging \
    --bucket MY-BUCKET \
    --bucket-logging-status file://logs-acl.json \
    --endpoint-url https://s3.eu-central-2.ionoscloud.com
```

Contents of `logs-acl.json`:

![Logging](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-58233e6746f7851d7d52b70fe33489e112269830%2Fs3-logging-cli.png?alt=media)

Retrieve bucket logging settings:

```bash
aws s3api get-bucket-logging \
   --bucket MY-BUCKET \
   --endpoint-url https://s3.eu-central-2.ionoscloud.com
```

Disable logging for a bucket:

```bash
aws s3api put-bucket-logging \
   --bucket MY-BUCKET \
   --bucket-logging-status '{}' \
   --endpoint-url https://s3.eu-central-2.ionoscloud.com
```
