hardcodet / serilog-sinks-awscloudwatch

A Serilog sink that logs to AWS CloudWatch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serilog Sink for AWS CloudWatch

This Serilog Sink allows to log to AWS CloudWatch. It supports .NET Framework 4.6 and .NET Core.

Version and build status

NuGet version

Build status

Usage

// name of the log group
var logGroupName = "myLogGroup/" + env.EnvironmentName;

// customer renderer (optional, defaults to a simple rendered message of Serilog's LogEvent
var renderer = new MyCustomRenderer();

// options for the sink, specifying the log group name
CloudWatchSinkOptions options = new CloudWatchSinkOptions {LogGroupName = logGroupName, LogEventRenderer = MyCustomRenderer};

// setup AWS CloudWatch client
AWSCredentials credentials = new BasicAWSCredentials(myAwsAccessKey, myAwsSecretKey);
IAmazonCloudWatchLogs client = new AmazonCloudWatchLogsClient(credentials, myAwsRegion);

// Attach the sink to the logger configuration
Log.Logger = new LoggerConfiguration().MinimumLevel.Information()
  .WriteTo.AmazonCloudWatch(options, client)
  .CreateLogger();

Contribution

We value your input as part of direct feedback to us, by filing issues, or preferably by directly contributing improvements:

  1. Fork this repository
  2. Create a branch
  3. Contribute
  4. Pull request

About

A Serilog sink that logs to AWS CloudWatch

License:Apache License 2.0


Languages

Language:C# 73.6%Language:PowerShell 26.4%