AWSDocAWS SDKGitHub サンプルリポジトリには、さらに多くの SDK サンプルがあります
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
CloudWatchAWSSDKを使用してLogs ロググループを記述する
以下のコード例は、CloudWatch Logs ロググループを記述する方法を示しています。
- .NET
-
- AWS SDK for .NET
-
注記
他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 using System; using System.Threading.Tasks; using Amazon.CloudWatchLogs; using Amazon.CloudWatchLogs.Model; /// <summary> /// Retrieves information about existing Amazon CloudWatch Logs log groups /// and displays the information on the console. The example was created /// using the AWS SDK for .NET version 3.7 and .NET Core 5.0. /// </summary> public class DescribeLogGroups { public static async Task Main() { // Creates a CloudWatch Logs client using the default // user. If you need to work with resources in another // AWS Region than the one defined for the default user, // pass the AWS Region as a parameter to the client constructor. var client = new AmazonCloudWatchLogsClient(); var request = new DescribeLogGroupsRequest { Limit = 5, }; var response = await client.DescribeLogGroupsAsync(request); if (response.LogGroups.Count > 0) { do { response.LogGroups.ForEach(lg => { Console.WriteLine($"{lg.LogGroupName} is associated with the key: {lg.KmsKeyId}."); Console.WriteLine($"Created on: {lg.CreationTime.Date.Date}"); Console.WriteLine($"Date for this group will be stored for: {lg.RetentionInDays} days.\n"); }); } while (response.NextToken is not null); } } }
-
API の詳細については、AWS SDK for .NETAPI DescribeLogGroupsリファレンスのを参照してください。
-
- JavaScript
-
- SDK for forJavaScript (v3)
-
注記
他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 import { DescribeLogGroupsCommand } from "@aws-sdk/client-cloudwatch-logs"; import { client } from "../libs/client.js"; const run = async () => { // This command will return a list of all log groups in your account. const command = new DescribeLogGroupsCommand({}); try { return await client.send(command); } catch (err) { console.error(err); } }; export default run();
-
API の詳細については、AWS SDK for JavaScriptAPI DescribeLogGroupsリファレンスのを参照してください。
-
エクスポートタスクの記述
クロスサービスの例