ArieGato / serilog-sinks-rabbitmq

Serilog Sink for RabbitMq
Apache License 2.0
53 stars 51 forks source link

Can't build a new exchange #123

Closed AsyncTaskSola closed 5 months ago

AsyncTaskSola commented 1 year ago

hello , I use this nuget ,when I setting this config in code .Find have a question,the rabbitmq can connect ,but can't build a exchange .Or is there something wrong with my configuration ?Nuget 6.0 and RabbitMQ 3.8.34 Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .Enrich.WithExceptionDetails() .WriteTo.RabbitMQ((clientConfiguration, sinkconfig) => { //ConnecttoRbbitMq(); clientConfiguration.Username = "guest"; clientConfiguration.Password = "guest"; clientConfiguration.Exchange = "rqlogstashExchange"; clientConfiguration.ExchangeType = ExchangeType.Direct; clientConfiguration.DeliveryMode = RabbitMQDeliveryMode.NonDurable; clientConfiguration.RouteKey = "rqlogstash"; clientConfiguration.Port = 5672; clientConfiguration.Hostnames.Add("127.0.0.1"); sinkconfig.TextFormatter = new JsonFormatter(); }) .ReadFrom.Configuration(configuration) .CreateLogger();

image image

sungam3r commented 5 months ago

Use autoCreateExchange parameter. As documentation says

If autoCreateExchange is true, the sink will create the exchange if an exchange by that name doesn't exist. Exchange is not created by default.

ArieGato commented 5 months ago

Tested and unable to reproduce