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>
2024-01-10 18:09:53 -06:00
/// 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." ) ;
}
}
}
2023-08-23 14:31:04 -05:00
2022-06-17 10:05:12 -04:00
// snippet-end:[CloudWatchLogs.dotnetv3.CreateLogGroupExample]
2023-08-23 14:31:04 -05:00
}