網頁

Thursday, October 14, 2021

[.NET 6] Implement custom LogProvider with RabbitMQ into ILogger

In .NET 6, ILogger is very easy to use, but on modern project, we will write log to somewhere else and use log viewer to read it. For example: sent log to RabbitMQ and read on Kibana

Here is a demo to show how to lmplement a custom logging provider with RabbitMQ into ILogger in .NET 6 RC1, basically same as this article but with some modify.

Step 0 : Before Start

In this demo we choose RabbitMQ.Client to communite with RabbitMQ, you can choose other client if you want, just install it from nuget, easy.

Another thing is RabbitMQ server, if you don't have one, you can use docker to create one.

docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.9-management