---
title: Changing log compression formats
summary: null
url: >-
  https://www.fastly.com/documentation/guides/integrations/streaming-logs/changing-log-compression-options
---

Fastly's [Real-Time Log Streaming](https://www.fastly.com/documentation/guides/integrations/streaming-logs/about-fastlys-realtime-log-streaming-features) feature allows you to specify compression format and options for file-based logging endpoints. These include the [Azure Blob](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/object-and-cloud-storage/log-streaming-azure-blob-storage), [FTP](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/protocol-based-and-self-hosted/log-streaming-ftp), [Google Cloud Storage](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/object-and-cloud-storage/log-streaming-google-cloud-storage), [Kafka](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/data-streaming-and-message-queues/log-streaming-kafka), [OpenStack](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/object-and-cloud-storage/log-streaming-openstack), [Amazon S3](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/object-and-cloud-storage/log-streaming-amazon-s3), [SFTP](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/protocol-based-and-self-hosted/log-streaming-sftp), [Digital Ocean](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/object-and-cloud-storage/log-streaming-digitalocean-spaces), and [Cloud Files](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/object-and-cloud-storage/log-streaming-cloudfiles) logging endpoints.

## Available log compression formats

Although the default is to use no compression, we allow you to choose one of several compression mechanisms:

- **[Zstandard](https://github.com/facebook/zstd)**, a compression algorithm defined by [RFC 8478](https://datatracker.ietf.org/doc/html/rfc8478)
- **[Snappy](https://github.com/google/snappy)**, a compression and decompression library used by many Google products as referenced in the [Snappy compressed format description](https://github.com/google/snappy/blob/a3e012d762a592423ec83717f7d685b594c0e8e3/format_description.txt)
- **[Gzip](https://www.gzip.org)**, a compression utility as defined in [RFC 1952](https://datatracker.ietf.org/doc/html/rfc1952) and [RFC 1951](https://datatracker.ietf.org/doc/html/rfc1951)

## Using a different compression format

### Fastly Control Panel

> **IMPORTANT:** If you're using Gzip compression, the Fastly control panel defaults to a Gzip compression level of 3 and can only be changed using the Logging API. If the Gzip compression level has been set to a value other than `3` via an API call, then that level is displayed as a read-only value.

  Follow these instructions to update a file-based logging endpoint's compression format using the Fastly control panel:

1.   Log in to the [Fastly control panel](https://manage.fastly.com).

2.   From the [**Home**](https://manage.fastly.com/home) page, select the appropriate service. You can use the search box to search by ID, name, or domain.

3.   Click **Edit configuration** and then select the option to clone the active version.

4. Click **Logging**.

5. Click the name of a file-based logging endpoint you want to edit.

6. Click **Advanced options** near the bottom of the page.

7. In the **Compression** section, select a compression format for the logging endpoint.

   ![Logging compression options](/img/compression_formats.png)

8. Click **Update**.

9.   From the **Activate** menu, select **Activate on Production** to deploy your configuration changes.

### API

You can use the [Logging API](https://www.fastly.com/documentation/reference/api/logging/) for any file-based logging endpoint to update the compression format.

  The API provides two fields for specifying log file compression options: `compression_codec` and `gzip_level`.

- `compression_codec` is a string that specifies the codec used to compress your logs. One of the following:
  - `zstd` Use [Zstandard](https://facebook.github.io/zstd/) compression.
  - `snappy` Use [Snappy](https://github.com/google/snappy) compression.
  - `gzip` Use [Gzip](https://www.gzip.org). Defaults to gzip compression level 3.

- `gzip_level` is an integer in the range of 0, signifying no compression, to 9, signifying maximum compression.

  > **IMPORTANT:** Use of `compression_codec` is recommended over use of `gzip_level` unless you need to set the gzip compression level to a value other than 3.

  Keep in mind the following with respect to the request payload:

- Only one of `compression_codec` or `gzip_level` should be included in a request payload. Specifying both will result in an error.

- If `compression_codec` is set to "gzip", `gzip_level` will default to 3.

- If `compression_codec` is not specified in the request payload and a non-zero value for `gzip_level` is set, then `compression_codec` will default to "gzip".

- If neither `compression_codec` nor `gzip_level` is specified in the request, no compression is applied to log files and `compression_codec` will default to `null`.

  For example, to update the compression format for a service's SFTP logging endpoint to use the Snappy compression codec, the curl command would look something like this:

  ```term copy
  $ curl -X PUT -H "Fastly-Key: YOUR_FASTLY_TOKEN"  -H "Accept: application/json" -d "compression_codec=snappy" https://api.fastly.com/service/SU1Z0isxPaozGVKXdv0eY/version/5/logging/sftp/sftp-log
  ```

  To apply gzip compression to an Azure Blob Storage logging endpoint using the `compression_codec` field, the curl command would look like this:

  ```term copy
  $ curl -X PUT -H "Fastly-Key: YOUR_FASTLY_TOKEN"  -H "Accept: application/json" -d "compression_codec=gzip" https://api.fastly.com/service/SU1Z0isxPaozGVKXdv0eY/version/7/logging/azureblob/azure-log
  ```

  To update a Google Cloud Storage logging endpoint's compression format to 1 using the `gzip_level` field, the curl command would look like this:

  ```term copy
  $ curl -X PUT -H "Fastly-Key: YOUR_FASTLY_TOKEN"  -H "Accept: application/json" -d "gzip_level=1" https://api.fastly.com/service/SU1Z0isxPaozGVKXdv0eY/version/4/logging/gcs/gcs-log
  ```

## Related content

- [Real-time log streaming](https://www.fastly.com/documentation/guides/integrations/streaming-logs/about-fastlys-realtime-log-streaming-features)
- [Logging API reference](https://www.fastly.com/documentation/reference/api/logging/)
- [Logging CLI reference](https://www.fastly.com/documentation/reference/cli/logging/)
