

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 创建事件日志配置
<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`，日志会被推送到`/aws/iotmanagedintegrations/EventLog`日志中的 CloudWatch 日志组。[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 检索特定配置。