Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

The-Poolz/Net.Utils.CloudWatchHandler

Repository files navigation

Net.Utils.CloudWatchHandler

CloudWatch Handler for .NET

CodeFactor

Quality Gate Status

Net.Utils.CloudWatchHandler is a .NET utility library that simplifies the process of creating and managing AWS CloudWatch log streams and messages.

Table of Contents

Installation

To install via NuGet:

Install-Package Net.Utils.CloudWatchHandler

Usage

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.");

Features

  • 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.

Contribution

Contributions are welcome! Please create a pull request in the GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Releases

No releases published

Packages

No packages published

Languages