I don't understand how to create a custom text formatter for Amazon Cloudwatch as mentioned:
var formatter = new MyCustomTextFormatter();
I am trying to write Serilog logs to Amazon CloudWatch instead of the local hard disk. To do that I am following this repo:
https://github.com/Cimpress-MCP/serilog-sinks-awscloudwatch
private readonly ITextFormatter textFormatter;
public ILoggerFactory ConfigureLogger()
{
LoggerFactory factory = new LoggerFactory();
var logGroupName = "myLoggrouName";
var region = Amazon.RegionEndpoint.EUWest1;
var client = new AmazonCloudWatchLogsClient(region);
//var formatter = new MyCustomTextFormatter();
var options = new CloudWatchSinkOptions()
{
LogGroupName = logGroupName,
//TextFormatter = formatter,
MinimumLogEventLevel = LogEventLevel.Information,
BatchSizeLimit = 100,
QueueSizeLimit = 10000,
Period = TimeSpan.FromSeconds(10),
CreateLogGroup = true,
LogStreamNameProvider = new DefaultLogStreamProvider(),
RetryAttempts = 5
};
Log.Logger = new LoggerConfiguration()
.WriteTo.AmazonCloudWatch(options, client)
.CreateLogger();
return factory;
}
To be able to write the Serilogs to Cloudwatch.