# Logging

Logging in <code class="expression">space.vars.ionos\_cloud\_object\_storage</code> supports the tracking and storage of requests made to your bucket. When you enable Logging, Object Storage automatically records access requests, such as the requester, bucket name, request time, request action, response status, and error codes, if any. By default, Logging is disabled for a bucket.

{% hint style="info" %}
**Note:** Logging is currently supported only for user-owned buckets and is available in the `de`, `eu-central-2`, and `eu-south-2` regions.
{% endhint %}

{% hint style="danger" %}
**Note:** Logging is not supported for contract-owned buckets.
{% endhint %}

## Use cases

* **Security Monitoring:** Tracks access patterns and identifies unauthorized or suspicious access to your data. In the event of a security breach, logs provide vital information for investigating the incident, such as IP addresses, request times, and the actions that were performed.
* **Auditing:** Many industries require compliance with specific regulatory standards that mandate the monitoring and logging of access to data. Logging facilitates compliance with regulations like HIPAA, GDPR, or SOX by providing a detailed record of who accessed what data and when.
* **Troubleshooting:** If there are issues with how applications are accessing your Object Storage data, logs can provide detailed information to help diagnose and resolve these issues. Logs show errors and the context in which they occurred, aiding in quick troubleshooting.

## Manage Logging

You can manage Logging using the DCD, API, and CLI.

### DCD

#### Activate Logging

{% hint style="info" %}
**Prerequisite:** Make sure you have provided access permissions for the Log Delivery Group. For more information, see [<mark style="color:blue;">Grant access permission for Logging</mark>](#grant-access-permission-for-logging).
{% endhint %}

To activate Logging, follow these steps:

1\. In the **DCD**, go to **Menu** > **Storage & Backup** > **IONOS Object Storage**.

2\. From the **Buckets** list, choose the bucket and click **Bucket settings**.

3\. Go to the **Logging** setting under the **Access management** section and click **Browse Object Storage** to select the destination bucket in the same region to store logs.

{% hint style="info" %}
**Note:** Although it is possible to store logs in the same bucket being logged, it is recommended to use a different bucket to avoid potential complications with managing log data and user data together.
{% endhint %}

4\. (Optional) Specify the prefix for log storage, providing flexibility in organizing and accessing your log data. If no prefix is entered, the log file name is derived from its time stamp alone.

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

5\. Click **Save**.

{% hint style="success" %}
**Result:** Logging is enabled for the selected bucket.
{% endhint %}

#### Deactivate Logging

You can modify or deactivate Logging at any time with no effect on existing log files. Log files are handled like any other object. Using the **Logging** section in the **Bucket settings**, you can click **Disable Logging** to stop collecting log data for a bucket.

#### Grant access permission for Logging

1\. In the **DCD**, go to **Menu** > **Storage & Backup** > **IONOS Object Storage**.

2\. From the **Buckets** list, choose the bucket for which the logging must be enabled.

3\. Click **Bucket settings** and go to the **Access Control List (ACL)**.

4\. For **Logging**, select the **OBJECTS:WRITE** and **BUCKET ACL:READ** checkboxes.

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

5\. Click **Save**.

{% hint style="success" %}
**Result:** The required access permissions to enable Logging for a bucket is granted.
{% endhint %}

### API

Use the [<mark style="color:blue;">API</mark>](https://api.ionos.com/docs/s3/v2/#tag/Logging) to configure and manage Logging for a bucket.

### CLI

Use [<mark style="color:blue;">CLI</mark>](https://docs.ionos.com/sections-test/guides/storage-and-backup/ionos-object-storage/s3-tools/awscli/awscli-logging) to manage Logging for buckets.

## Limitations

Logs can only be stored in the same-region buckets.

{% hint style="warning" %}
**Warning:** Although it is possible to store logs in the same bucket being logged, it is not recommended due to potential complications with managing log data and user data together.
{% endhint %}

## Related feature

### Lifecycle Management

Use [<mark style="color:blue;">Lifecycle Management</mark>](https://docs.ionos.com/sections-test/guides/storage-and-backup/ionos-object-storage/settings/lifecycle) in conjunction with Logging to manage and automate the lifecycle of log files. For instance, you can set up a lifecycle policy to permanently delete logs that are no longer needed after a certain period.
