Вот проблемная часть моего простого примера приложения:
Код: Выделить всё
var builder = WebApplication
.CreateBuilder(args);
builder.Host.UseSerilog((ctx, lc) => lc
.MinimumLevel.Debug()
.WriteTo.Console()
.WriteTo.Elasticsearch(new[] { new Uri("http://localhost:9200") }, opts =>
{
opts.MinimumLevel = Serilog.Events.LogEventLevel.Error;
opts.BootstrapMethod = BootstrapMethod.Failure;
opts.LevelSwitch = SwitchProvider.ElasticSwitch;
opts.DataStream = new DataStreamName("logs", "web-api-example");
})
);
Я также пытался переключить уровень приемника Elasticsearch во время выполнения с помощью
Код: Выделить всё
ElasticSwitch.MinimumLevel = Serilog.Events.LogEventLevel.Error;
Код: Выделить всё
public static class SwitchProvider
{
public static LoggingLevelSwitch ElasticSwitch = new LoggingLevelSwitch();
}
Я что-то упустил?
Подробнее здесь: https://stackoverflow.com/questions/786 ... -reflected