Hi,
Not sure if my previous questions has reached the group, so I'll try once again.
I'm having some difficulties to hook up RabbitMQ to Serilog, in an ASP.Net Core app.
RabbitMQ works fine directly from C# code (I have some other queues and an exchange working, no problem).
Serilog works fine writing to a File, via appsettings.json.
The combination however, is where my problem lies. I do not succeed in providing the correct settings inside the appsettings.json for Serilog to log to a RabbitMQ exchange / queue.
My appsettings sofar:
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"Serilog": {
"Using": ["Serilog.Sinks.RabbitMQ"],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "RabbitMQ",
"Args": {
"Hostnames": [ "localhost" ],
"Port": 15672,
"Exchange": "myExchange",
"ExchangeType": "direct",
"RouteKey": "logging",
"DeliveryMode": "RabbitMQDeliveryMode.Durable"
}
},
{
"Name": "File",
"Args": {
"path": "MyLogFile_.log",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}",
"rollingInterval": "Day"
}
}
]
}
}
I have referenced Serilog.Sinks.RabbitMQ, version 3.0.3
Exchange Binding to Queue is correctly setup, Routing Key is also correct inside RabbitMQ.
I have tried to provide username, password, vhost, and all sorts of casing combinations etc. However, it will not log :-(
The call inside Main is like this, using DI:
_logger.LogInformation("Hooray, I'm started!");
This line is being logged to File correctly, but I also would like to have it logged to RabbitMQ.
Any ideas what I might be doing wrong?
Thanks in advance for your help,
Tom