

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 建立事件日誌組態
<a name="logging-create-config"></a>

使用 [CreateEventLogConfiguration](https://docs.aws.amazon.com/iot-mi/latest/APIReference/API_CreateEventLogConfiguration.html) API 動作來啟用資源類型的事件記錄。我們建議為每個資源類型建立單獨的組態，使用 `*`作為資源識別符來擷取該類型所有資源的日誌。從`ERROR`日誌層級開始，接收所有失敗日誌，而不會產生過多的磁碟區或成本。

```
aws iot-managed-integrations create-event-log-configuration \
    --resource-type "managed-thing" \
    --resource-id "*" \
    --event-log-level "ERROR"
```

針對每個資源類型重複此步驟：

```
aws iot-managed-integrations create-event-log-configuration \
    --resource-type "credential-locker" \
    --resource-id "*" \
    --event-log-level "ERROR"

aws iot-managed-integrations create-event-log-configuration \
    --resource-type "provisioning-profile" \
    --resource-id "*" \
    --event-log-level "ERROR"

aws iot-managed-integrations create-event-log-configuration \
    --resource-type "ota-task" \
    --resource-id "*" \
    --event-log-level "ERROR"

aws iot-managed-integrations create-event-log-configuration \
    --resource-type "account-association" \
    --resource-id "*" \
    --event-log-level "ERROR"
```

呼叫 後`CreateEventLogConfiguration`，日誌會推送到 CloudWatch `/aws/iotmanagedintegrations/EventLog` Logs 中的日誌群組。使用 [ListEventLogConfigurations](https://docs.aws.amazon.com/iot-mi/latest/APIReference/API_ListEventLogConfigurations.html) 來檢視所有組態，或使用 [GetEventLogConfiguration](https://docs.aws.amazon.com/iot-mi/latest/APIReference/API_GetEventLogConfiguration.html) 依 ID 擷取特定組態。