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

# Traffic Log Settings

> Manage traffic log settings for API proxies. Configure per-environment and per-connector log collection with granular control over what data is logged, size limits, and privacy settings.

## Endpoints

| Method | Path                                                                                                                                             | Description                       |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------- |
| GET    | `/apiops/projects/{projectName}/apiProxies/{apiProxyName}/trafficLogSettings/`                                                                   | List all environments' settings   |
| GET    | `/apiops/projects/{projectName}/apiProxies/{apiProxyName}/trafficLogSettings/{environmentName}/`                                                 | Get specific environment settings |
| PUT    | `/apiops/projects/{projectName}/apiProxies/{apiProxyName}/trafficLogSettings/{environmentName}/`                                                 | Update environment settings       |
| PUT    | `/apiops/projects/{projectName}/apiProxies/{apiProxyName}/trafficLogSettings/{environmentName}/methods/{methodName}/connectors/{connectorType}/` | Update method-level override      |
| DELETE | `/apiops/projects/{projectName}/apiProxies/{apiProxyName}/trafficLogSettings/{environmentName}/methods/{methodName}/connectors/{connectorType}/` | Delete method-level override      |

#### Update Method-Level Connector Override

```plaintext theme={null}
PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/trafficLogSettings/{environmentName}/methods/{methodName}/connectors/{connectorType}/
```

#### Delete Method-Level Connector Override

```plaintext theme={null}
DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/trafficLogSettings/{environmentName}/methods/{methodName}/connectors/{connectorType}/
```

***

## List All Environments' Settings

### Endpoint

```plaintext theme={null}
GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/trafficLogSettings/
```

## Path Parameters

| Parameter       | Type   | Required    | Description                                                                                                                                                                                                                 |
| --------------- | ------ | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| projectName     | string | Yes         | Project name                                                                                                                                                                                                                |
| apiProxyName    | string | Yes         | API Proxy name                                                                                                                                                                                                              |
| environmentName | string | Yes         | Environment name (e.g., `production`, `tester`)                                                                                                                                                                             |
| methodName      | string | Conditional | API method name (only for method-level endpoints)                                                                                                                                                                           |
| connectorType   | string | Conditional | Connector type (only for method-level endpoints). Values: `ELASTICSEARCH_INDEX`, `DB_INSERT_UPDATE_DELETE`, `SYSLOG_SEND`, `WEBHOOK_SEND`, `RABBITMQ_SEND`, `ACTIVEMQ_SEND`, `KAFKA_SEND`, `GRAYLOG_SEND`, `LOGBACK_APPEND` |

***

## GET: List All Environments' Settings

Returns traffic log settings for all environments of the specified API Proxy. Connector keys are returned as **connection names** (not internal UUIDs).

### cURL Example

```bash theme={null}
curl -X GET \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/trafficLogSettings/" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

***

## GET: Specific Environment Settings

Returns traffic log settings for a single environment.

### cURL Example

```bash theme={null}
curl -X GET \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/trafficLogSettings/production/" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

***

## PUT: Update Environment Settings

Updates traffic log settings for a specific environment and deploys the changes.

### Response

```json theme={null}
{
  "logParamRequestFromClient": true,
  "logHeaderRequestFromClient": true,
  "logBodyRequestFromClient": true,
  "logParamRequestToTarget": true,
  "logHeaderRequestToTarget": true,
  "logBodyRequestToTarget": true,
  "logHeaderResponseFromTarget": true,
  "logBodyResponseFromTarget": true,
  "logHeaderResponseToClient": true,
  "logBodyResponseToClient": true,
  "connectorSettingsMap": {
    "my-elasticsearch-connection": {
      "enabled": true,
      "logHeaderRequestFromClient": true,
      "logBodyRequestFromClient": true,
      "logBodyResponseFromTarget": true,
      "enableMetadataIdentification": true,
      "enableMetadataApiProxy": true,
      "enableMetadataRequest": true,
      "enableMetrics": true,
      "enableMetadataResponse": true,
      "enableSentAddress": true,
      "enableBodyFromClientSize": true,
      "sizeBodyFromClient": 2048,
      "enableBodyToTargetSize": true,
      "sizeBodyToTarget": 2048,
      "enableBodyFromTargetSize": true,
      "sizeBodyFromTarget": 2048,
      "enableBodyToClientSize": true,
      "sizeBodyToClient": 2048,
      "enablePrivacy": false,
      "privacyDefinitionList": []
    },
    "my-kafka-connection": {
      "enabled": true,
      "logBodyRequestFromClient": true,
      "logBodyResponseFromTarget": true
    }
  }
}
```

### Request Body Fields (Top-Level)

| Field                       | Type    | Required | Default | Description                                                                               |
| --------------------------- | ------- | -------- | ------- | ----------------------------------------------------------------------------------------- |
| logParamRequestFromClient   | boolean | No       | true    | Log query parameters from client request                                                  |
| logHeaderRequestFromClient  | boolean | No       | true    | Log headers from client request                                                           |
| logBodyRequestFromClient    | boolean | No       | true    | Log body from client request                                                              |
| logParamRequestToTarget     | boolean | No       | true    | Log query parameters sent to target                                                       |
| logHeaderRequestToTarget    | boolean | No       | true    | Log headers sent to target                                                                |
| logBodyRequestToTarget      | boolean | No       | true    | Log body sent to target                                                                   |
| logHeaderResponseFromTarget | boolean | No       | true    | Log headers from target response                                                          |
| logBodyResponseFromTarget   | boolean | No       | true    | Log body from target response                                                             |
| logHeaderResponseToClient   | boolean | No       | true    | Log headers sent to client response                                                       |
| logBodyResponseToClient     | boolean | No       | true    | Log body sent to client response                                                          |
| connectorSettingsMap        | object  | No       | {}      | Per-connector settings. **Key = connection name** (as defined in Connections). See below. |
| methodOverrideList          | array   | No       | \[]     | Method-level connector overrides. See below.                                              |

### connectorSettingsMap

The `connectorSettingsMap` is an object where each **key is the connection name** and each value contains the connector-specific log settings.

**Important:** The connection must already exist and be configured as a connector (recipient) in the target environment. Use the [Connections API](/api-reference/connections/connections/connection-elasticsearch) to create connections first.

#### Connector Log Settings Fields

| Field                        | Type    | Required | Default | Description                                     |
| ---------------------------- | ------- | -------- | ------- | ----------------------------------------------- |
| enabled                      | boolean | No       | false   | Enable/disable this connector                   |
| logParamRequestFromClient    | boolean | No       | null    | Override: log query params from client          |
| logHeaderRequestFromClient   | boolean | No       | null    | Override: log headers from client               |
| logBodyRequestFromClient     | boolean | No       | null    | Override: log body from client                  |
| logParamRequestToTarget      | boolean | No       | null    | Override: log query params to target            |
| logHeaderRequestToTarget     | boolean | No       | null    | Override: log headers to target                 |
| logBodyRequestToTarget       | boolean | No       | null    | Override: log body to target                    |
| logHeaderResponseFromTarget  | boolean | No       | null    | Override: log headers from target               |
| logBodyResponseFromTarget    | boolean | No       | null    | Override: log body from target                  |
| logHeaderResponseToClient    | boolean | No       | null    | Override: log headers to client                 |
| logBodyResponseToClient      | boolean | No       | null    | Override: log body to client                    |
| enableMetadataIdentification | boolean | No       | null    | Log identification metadata                     |
| enableMetadataApiProxy       | boolean | No       | null    | Log API proxy metadata                          |
| enableMetadataRequest        | boolean | No       | null    | Log request metadata (IP, method, path, etc.)   |
| enableMetrics                | boolean | No       | null    | Log performance metrics (timing, size, retry)   |
| enableMetadataResponse       | boolean | No       | null    | Log response metadata (status code, error type) |
| enableSentAddress            | boolean | No       | null    | Log routing address                             |
| enableBodyFromClientSize     | boolean | No       | null    | Enable size limit for client request body       |
| sizeBodyFromClient           | integer | No       | null    | Max KB for client request body                  |
| enableBodyToTargetSize       | boolean | No       | null    | Enable size limit for target request body       |
| sizeBodyToTarget             | integer | No       | null    | Max KB for target request body                  |
| enableBodyFromTargetSize     | boolean | No       | null    | Enable size limit for target response body      |
| sizeBodyFromTarget           | integer | No       | null    | Max KB for target response body                 |
| enableBodyToClientSize       | boolean | No       | null    | Enable size limit for client response body      |
| sizeBodyToClient             | integer | No       | null    | Max KB for client response body                 |
| enablePrivacy                | boolean | No       | false   | Enable privacy masking                          |
| privacyDefinitionList        | array   | No       | \[]     | Privacy masking rules                           |

**Note:** Fields set to `null` inherit from the parent (proxy-level defaults).

### cURL Example: Enable Elasticsearch and Kafka Logging

```bash theme={null}
curl -X PUT \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/trafficLogSettings/production/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "logHeaderRequestFromClient": true,
    "logBodyRequestFromClient": true,
    "logBodyResponseFromTarget": true,
    "connectorSettingsMap": {
      "my-elasticsearch-connection": {
        "enabled": true,
        "logBodyRequestFromClient": true,
        "logBodyResponseFromTarget": true,
        "enableBodyFromClientSize": true,
        "sizeBodyFromClient": 1024
      },
      "my-kafka-connection": {
        "enabled": true,
        "logBodyRequestFromClient": true
      }
    }
  }'
```

### cURL Example: Minimal — Enable Only Elasticsearch

```bash theme={null}
curl -X PUT \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/trafficLogSettings/tester/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "connectorSettingsMap": {
      "my-elasticsearch-connection": {
        "enabled": true
      }
    }
  }'
```

***

## PUT: Method-Level Connector Override

Adds or updates a method-level connector override. This allows different log settings for specific API methods.

### Path

```
PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/trafficLogSettings/{environmentName}/methods/{methodName}/connectors/{connectorType}/
```

### Request Body

Same as [Connector Log Settings Fields](#connector-log-settings-fields) above.

### cURL Example

```bash theme={null}
curl -X PUT \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/trafficLogSettings/production/methods/getUserById/connectors/ELASTICSEARCH_INDEX/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true,
    "logBodyRequestFromClient": false,
    "logBodyResponseFromTarget": true,
    "enableBodyFromTargetSize": true,
    "sizeBodyFromTarget": 512
  }'
```

***

## DELETE: Method-Level Connector Override

Removes a method-level connector override, reverting to proxy-level settings.

### cURL Example

```bash theme={null}
curl -X DELETE \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/trafficLogSettings/production/methods/getUserById/connectors/ELASTICSEARCH_INDEX/" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

***

## Response

### Success Response (200 OK)

```json theme={null}
{
  "status": "SUCCESS",
  "resultList": [
    {
      "environmentId": "env-123",
      "apiProxyId": "proxy-456",
      "logParamRequestFromClient": true,
      "logBodyRequestFromClient": true,
      "connectorSettingsMap": {
        "my-elasticsearch-connection": {
          "enabled": true,
          "logBodyRequestFromClient": true
        }
      }
    }
  ]
}
```

### Error Response (400 Bad Request)

```json theme={null}
{
  "status": "FAILURE",
  "resultMessage": "Connection with name 'non-existent-connection' not found!"
}
```

#### Common Error Messages

| Message                                                               | Cause                                                                       |
| --------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| `Connection with name 'X' not found!`                                 | Connection name does not exist in the project or admin project              |
| `Connection 'X' is not configured as a connector in the environment!` | Connection exists but is not added as a recipient in the target environment |
| `environmentName value can not be empty!`                             | Missing environment name                                                    |
| `Environment (X) is not found!`                                       | Environment does not exist                                                  |
| `Method (X) is not found in ApiProxy!`                                | Method name does not exist in the API proxy                                 |
| `Invalid connectorType: X`                                            | Invalid EnumExecutableType value                                            |

## Notes and Warnings

* **Connection Names**: Use the connection name as the key in `connectorSettingsMap`, not the connection type or ID. The API resolves names to internal IDs automatically.
* **Environment Recipient**: The connection must be added as a connector (recipient) in the target environment before it can be used here.
* **Inheritance**: `null` fields in connector settings inherit from proxy-level defaults. Method-level overrides inherit from proxy-level connector settings.
* **Trailing Slash**: All URLs **must** end with `/`. Without it, you will get a 404 error.
* **Deploy**: PUT operations automatically deploy the changes to the environment.

## Permissions

User must have **`API_MANAGEMENT` + `VIEW`** permission for GET endpoints and **`API_MANAGEMENT` + `MANAGE`** permission for PUT/DELETE endpoints.

## Related Documentation

* [Connections API](/api-reference/connections/connections/connection-elasticsearch) - Create and manage connections
* [Get API Proxy](/api-reference/api-proxies/crud/get-api-proxy) - Get API proxy details
