Closed tsvetelintsonev closed 5 years ago
The current configuration api is cumbersome with a lot of overload methods and large number of parameters. Using configuration via lambda expression will be more intuitive and easy to use
Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .WriteTo.RabbitMQ((clientConfiguration, sinkConfiguration) => { clientConfiguration.Hostnames = _config["RABBITMQ_HOSTS"]; clientConfiguration.Username = _config["RABBITMQ_USER"]; clientConfiguration.Password = _config["RABBITMQ_PASSWORD"]; clientConfiguration.Exchange = _config["RABBITMQ_EXCHANGE"]; clientConfiguration.ExchangeType = _config["RABBITMQ_EXCHANGE_TYPE"]; clientConfiguration.DeliveryMode = RabbitMQDeliveryMode.Durable; clientConfiguration.RouteKey = "Logs"; clientConfiguration.Port = 5672; sinkConfiguration.TextFormatter = new JsonFormatter(); }) .CreateLogger();
In order to support configuration via app settings binding the following api can be added
var config= new RabbitMQConfiguration { Hostnames = _config["RABBITMQ_HOSTS"], Username = _config["RABBITMQ_USER"], Password = _config["RABBITMQ_PASSWORD"], Exchange = _config["RABBITMQ_EXCHANGE"], ExchangeType = _config["RABBITMQ_EXCHANGE_TYPE"], DeliveryMode = RabbitMQDeliveryMode.Durable, RouteKey = "Logs", Port = 5672 }; Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .WriteTo.RabbitMQ((clientConfiguration, sinkConfiguration) => { clientConfiguration.From(config); sinkConfiguration.TextFormatter = new JsonFormatter(); }) .CreateLogger();
Closed with #69
The current configuration api is cumbersome with a lot of overload methods and large number of parameters. Using configuration via lambda expression will be more intuitive and easy to use
In order to support configuration via app settings binding the following api can be added