View a markdown version of this page

DeleteSyslogConfiguration 搭配 AWS SDK 使用 - Amazon CloudWatch Logs

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

DeleteSyslogConfiguration 搭配 AWS SDK 使用

以下程式碼範例顯示如何使用 DeleteSyslogConfiguration。

動作範例是大型程式的程式碼摘錄,必須在內容中執行。您可以在下列程式碼範例的內容中看到此動作:

Python
適用於 Python 的 SDK (Boto3)
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

def delete_syslog_configuration( self, log_group_identifier: str, vpc_endpoint_id: str ) -> None: """ Deletes a syslog configuration for a log group. After deletion, syslog data is no longer ingested through the specified VPC endpoint. :param log_group_identifier: The name or ARN of the log group. :param vpc_endpoint_id: The ID of the VPC endpoint associated with the syslog configuration. :raises ClientError: If the syslog configuration does not exist (in which case the error is logged but not re-raised during cleanup). """ try: self.logs_client.delete_syslog_configuration( logGroupIdentifier=log_group_identifier, vpcEndpointId=vpc_endpoint_id, ) logger.info( "Deleted syslog configuration for log group '%s' and VPC endpoint '%s'.", log_group_identifier, vpc_endpoint_id, ) except ClientError as error: if error.response["Error"]["Code"] == "ResourceNotFoundException": logger.info( "Syslog configuration does not exist or was already deleted: %s", error.response["Error"]["Message"], ) else: logger.error( "Failed to delete syslog configuration: %s", error.response["Error"]["Message"], ) raise
  • 如需 API 詳細資訊,請參閱《適用於 AWS Python (Boto3) 的 SDK API 參考》中的 DeleteSyslogConfiguration。

如需 AWS SDK 開發人員指南和程式碼範例的完整清單,請參閱 搭配 AWS SDK 使用 CloudWatch Logs。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。