CloudWatch Handler for .NET
Net.Utils.CloudWatchHandler
is a .NET utility library that simplifies the process of creating and managing AWS CloudWatch log streams and messages.
To install via NuGet:
Install-Package Net.Utils.CloudWatchHandler
Below is a basic example showcasing how to use the CloudWatchLogs
service for logging messages.
using Net.Utils.CloudWatchHandler.Services;
using Amazon.CloudWatchLogs;
// Configure AWS CloudWatch client
IAmazonCloudWatchLogs cloudWatchClient = new AmazonCloudWatchLogsClient();
// Configure logging
var logConfig = new LogConfig
{
LogGroup = "YourLogGroup",
LogStreamNamePrefix = "YourLogStreamPrefix",
Region = "us-east-1",
RestrictedToMinimumLevel = Serilog.Events.LogEventLevel.Information,
AppendHostName = true,
AppendUniqueInstanceGuid = true
};
// Create CloudWatchLogs instance
var cloudWatchLogs = CloudWatchLogs.Create(logConfig, cloudWatchClient);
// Log a message
cloudWatchLogs.Logger.Information("This is a test log message.");
- Simplifies creation and management of AWS CloudWatch log streams.
- Creates a new log stream once per day, optimizing resource usage.
- Appends messages to the same log stream within a single day.
- Provides a simplified interface for sending messages to CloudWatch.
- Includes a customizable message formatter.
Contributions are welcome! Please create a pull request in the GitHub repository.
This project is licensed under the MIT License - see the LICENSE file for details.