Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan PutSyslogConfigurationdengan AWS SDK
Contoh kode berikut menunjukkan cara menggunakanPutSyslogConfiguration.
Contoh tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Anda dapat melihat tindakan ini dalam konteks dalam contoh kode berikut:
- Python
-
- SDK untuk Python (Boto3)
-
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS.
def put_syslog_configuration(
self, log_group_identifier: str, vpc_endpoint_id: str
) -> None:
"""
Creates or updates a syslog configuration for a log group. This enables
ingestion of syslog data through the specified VPC endpoint.
:param log_group_identifier: The name or ARN of the log group to associate
with the syslog configuration.
:param vpc_endpoint_id: The ID of the VPC endpoint to use for syslog
ingestion.
:raises ClientError: If the log group or VPC endpoint does not exist.
"""
try:
self.logs_client.put_syslog_configuration(
logGroupIdentifier=log_group_identifier,
vpcEndpointId=vpc_endpoint_id,
)
logger.info(
"Created syslog configuration for log group '%s' with VPC endpoint '%s'.",
log_group_identifier,
vpc_endpoint_id,
)
except ClientError as error:
if error.response["Error"]["Code"] == "ResourceNotFoundException":
logger.error(
"The specified log group or VPC endpoint does not exist: %s",
error.response["Error"]["Message"],
)
else:
logger.error(
"Failed to put syslog configuration: %s",
error.response["Error"]["Message"],
)
raise
Untuk daftar lengkap panduan pengembang AWS SDK dan contoh kode, lihatMenggunakan CloudWatch Log dengan AWS SDK. Topik ini juga mencakup informasi tentang memulai dan detail tentang versi SDK sebelumnya.