SIGN IN SIGN UP

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.

0 0 230 Java
2021-10-04 08:42:45 -04:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
namespace CreateLogGroupExample
{
2022-06-17 10:05:12 -04:00
// snippet-start:[CloudWatchLogs.dotnetv3.CreateLogGroupExample]
2021-10-04 08:42:45 -04:00
using System;
using System.Threading.Tasks;
using Amazon.CloudWatchLogs;
using Amazon.CloudWatchLogs.Model;
/// <summary>
/// Shows how to create an Amazon CloudWatch Logs log group.
2021-10-04 08:42:45 -04:00
/// </summary>
public class CreateLogGroup
{
public static async Task Main()
{
// This client object will be associated with the same AWS Region
// as the default user on this system. If you need to use a
// different AWS Region, pass it as a parameter to the client
// constructor.
var client = new AmazonCloudWatchLogsClient();
string logGroupName = "cloudwatchlogs-example-loggroup";
var request = new CreateLogGroupRequest
{
LogGroupName = logGroupName,
};
var response = await client.CreateLogGroupAsync(request);
if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
{
Console.WriteLine($"Successfully create log group with ID: {logGroupName}.");
}
else
{
Console.WriteLine("Could not create log group.");
}
}
}
2022-06-17 10:05:12 -04:00
// snippet-end:[CloudWatchLogs.dotnetv3.CreateLogGroupExample]
}