protected virtual LoggerConfiguration GetLoggerConfiguration(ColidStatisticsLogOptions options) { if (options.Enabled == false) { return(new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.Console()); } return(new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(options.BaseUri) { NumberOfShards = 1, ModifyConnectionSettings = conn => { var httpConnection = _awsHttpConnection; var pool = new SingleNodeConnectionPool(options.BaseUri); return new ConnectionConfiguration(pool, httpConnection); }, IndexFormat = IndexFormat(options), FailureCallback = e => { Console.WriteLine("Error: Unable to submit event " + e.MessageTemplate); if (e.Exception != null) { Console.WriteLine(e.Exception.StackTrace); } }, EmitEventFailure = EmitEventFailureHandling.WriteToSelfLog | EmitEventFailureHandling.WriteToFailureSink | EmitEventFailureHandling.RaiseCallback, CustomFormatter = new ElasticsearchJsonFormatter(), })); }
protected string IndexFormat(ColidStatisticsLogOptions options) { return($"{options.DefaultIndex}-{Suffix()}-" + "{0:yyyy.MM}"); }
private ILogger GetLogger(ColidStatisticsLogOptions options) { return(GetLoggerConfiguration(options).CreateLogger()); }
protected override LoggerConfiguration GetLoggerConfiguration(ColidStatisticsLogOptions options) { return(base.GetLoggerConfiguration(options) .WriteTo.Console(LogEventLevel.Error)); }