Serilog.Sinks.RabbitMQ 7.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Serilog.Sinks.RabbitMQ --version 7.0.1
NuGet\Install-Package Serilog.Sinks.RabbitMQ -Version 7.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Serilog.Sinks.RabbitMQ" Version="7.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Sinks.RabbitMQ --version 7.0.1
#r "nuget: Serilog.Sinks.RabbitMQ, 7.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Serilog.Sinks.RabbitMQ as a Cake Addin
#addin nuget:?package=Serilog.Sinks.RabbitMQ&version=7.0.1

// Install Serilog.Sinks.RabbitMQ as a Cake Tool
#tool nuget:?package=Serilog.Sinks.RabbitMQ&version=7.0.1



codecov Nuget Nuget

GitHub Release Date GitHub commits since latest release (by date) Size

GitHub contributors Activity Activity Activity

Run unit tests Publish preview to GitHub registry Publish release to Nuget registry CodeQL analysis


This project is to allow Serilog to log to RabbitMQ using the RabbitMQ.Client package. The aim is to expose RabbitMQ.Client functionality, in a logical way, and not to build in additional logic into the sink. So expect pure RabbitMQ.Client behavior, but perhaps a little bit simpler interface.


As of v3.0.0 we use Semantic Versioning to express changes in the API.


Serilog.Sinks.RabbitMQ .NETStandard .NETFramework Serilog RabbitMQ.Client
2.0.0 1.6.0 4.5.1 2.3.0 4.*
3.0.0 1.6.1 4.5.1 2.8.0 5.*
6.0.0 2.0.0 4.7.2 2.8.0 6.*
7.0.0 2.0.0 - 3.1.1 6.8.*


Using Nuget:

Install-Package Serilog.Sinks.RabbitMQ

Release Notes

See changelog.


Sink Configuration Options

The sink can be configured completely through code, by using configuration files (or other types of configuration providers), a combination of both, or by using the various Serilog configuration packages. The sink is configured with a typical Serilog WriteTo configuration method (or AuditTo, or similar variations).

All sink configuration methods accept the following arguments, though not necessarily in this order. Use of named arguments is strongly recommended.

  • hostnames
  • username
  • password
  • exchange
  • exchangeType
  • deliveryMode
  • routeKey
  • port
  • vHost
  • heartbeat
  • sslEnabled
  • sslServerName
  • sslVersion
  • sslAcceptablePolicyErrors
  • sslCheckCertificateRevocation
  • batchPostingLimit
  • period
  • queueLimit
  • formatter
  • autoCreateExchange
  • maxChannels
  • levelSwitch


Parameters exchange, exchangeType, deliveryMode, routeKey provide additional configuration when connecting to RabbitMQ. 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.

If sslEnabled is true, the sink will use secure connection to server. By default, the server name is the same as the host name, no TLS version is specified, no server certificate errors are accepted, and certificate revocation checking is disabled. You can change server name through by setting the sslServerName, sslVersion, sslAcceptablePolicyErrors, sslCheckCertificateRevocation arguments.

This is a "periodic batching sink." The sink will queue a certain number of log events before they're actually written to RabbitMQ. There is also a timeout period so that the batch is always written even if it has not been filled. By default, the batch size is 50 rows and the timeout is 2 seconds. You can change these through by setting the batchPostingLimit and period arguments.

Refer to the Formatter for details about the formatter arguments.

Code-Only (any .NET target)

All sink features are configurable from code. Here is a typical example that works the same way for any .NET target.

Log.Logger = new LoggerConfiguration()
        username: "usr",
        password: "pwd",
        hostnames: new[] { "localhost" },
        port: 5672,
        exchange = "LogExchange",
        formatter: new JsonFormatter()

External configuration using Serilog.Settings.AppSettings

Refer to the Serilog.Settings.AppSettings package documentation for complete details about sink configuration. This is an example of setting some of the configuration parameters for this sink.

<add key="serilog:using:RabbitMQ" value="Serilog.Sinks.RabbitMQ"/>
<add key="serilog:write-to:RabbitMQ.username" value="user"/>
<add key="serilog:write-to:RabbitMQ.password" value="pwd"/>
<add key="serilog:write-to:RabbitMQ.hostnames" value="server1,server2"/>
<add key="" value="LogExchange"/>
<add key="serilog:write-to:RabbitMQ.batchPostingLimit" value="1000"/>
<add key="serilog:write-to:RabbitMQ.period" value="00:00:30"/>

External configuration using Serilog.Settings.Configuration

Refer to the Serilog.Settings.Configuration package documentation for complete details about sink configuration. Keys and values are not case-sensitive. This is an example of configuring the sink arguments.

  "Serilog": {
    "Using":  ["Serilog.Sinks.RabbitMQ"],
    "MinimumLevel": "Debug",
    "WriteTo": [
        "Name": "RabbitMQ", 
        "Args": { 
          "username": "usr",
          "password": "pwd",
          "hostnames": [
          "port": 5672,
          "exchange": "LogExchange",
          "autoCreateExchange": true,
          "batchPostingLimit": 1000,
          "period": 30

Audit Sink Configuration

A Serilog audit sink writes log events which are of such importance that they must succeed, and that verification of a successful write is more important than write performance. Unlike the regular sink, an audit sink does not fail silently - it can throw exceptions. You should wrap audit logging output in a try/catch block. The usual example is bank account withdrawal events - a bank would certainly not want to allow a failure to record those transactions to fail silently.

The constructor accepts most of the same arguments, and like other Serilog audit sinks, you configure one by using AuditTo instead of WriteTo.

  • hostnames
  • username
  • password
  • exchange
  • exchangeType
  • deliveryMode
  • routeKey
  • port
  • vHost
  • heartbeat
  • sslEnabled
  • sslServerName
  • sslVersion
  • sslAcceptablePolicyErrors
  • sslCheckCertificateRevocation
  • formatter
  • autoCreateExchange
  • maxChannels
  • levelSwitch

The batchPostingLimit and period parameters are not available because the audit sink writes log events immediately.

Multihost Configuration

The sink can be configured taking multiple host names.
To keep the Serilog.Setting.ApSettings external configuration, additional hosts are added to the hostnames argument separated by commas. This is an example of configuring the multihost using Serilog.Settings.AppSettings.

<add key="serilog:using:RabbitMQ" value="Serilog.Sinks.RabbitMQ"/>
<add key="serilog:write-to:RabbitMQ.hostnames" value="host1,host2"/>
<add key="serilog:write-to:RabbitMQ.username" value="user"/>
<add key="serilog:write-to:RabbitMQ.pasword" value="pwd"/>

Use protected configuration (ASP.NET)

ASP.NET has the possibility to encrypt connection string in the web.config.

Configuration via code

There are multiple ways for configuring the RabbitMQSink with the release of v3.0.0

Log.Logger = new LoggerConfiguration()
    .WriteTo.RabbitMQ((clientConfiguration, sinkConfiguration) =>
        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;

        foreach (string hostname in _config.GetSection("RABBITMQ_HOSTNAMES").Get<string[]>())

        sinkConfiguration.TextFormatter  = new JsonFormatter();
// Or
var config = new RabbitMQClientConfiguration
    Port            = 5672,
    DeliveryMode    = RabbitMQ.RabbitMQDeliveryMode.Durable,
    Exchange        = "test_exchange",
    Username        = "guest",
    Password        = "guest",
    ExchangeType    = "fanout"

foreach (string hostname in _config["RABBITMQ_HOSTNAMES"])
    config .Hostnames.Add(hostname);

Log.Logger = new LoggerConfiguration()
    .WriteTo.RabbitMQ((clientConfiguration, sinkConfiguration) =>
        sinkConfiguration.TextFormatter = new JsonFormatter();
    }) .CreateLogger();
// Or
Log.Logger = new LoggerConfiguration()
    .WriteTo.RabbitMQ((clientConfiguration, sinkConfiguration) =>
        clientConfiguration.From(Configuration.Bind("RabbitMQClientConfiguration", new RabbitMQClientConfiguration()));
        sinkConfiguration.TextFormatter = new JsonFormatter();
// Or
LoggerConfiguration loggerConfiguration = new LoggerConfiguration();
IConfigurationSection rabbitMqSection = configuration.GetSection("log:rabbitMq");
loggerConfiguration = loggerConfiguration
    .WriteTo.RabbitMQ((clientConfiguration, sinkConfiguration) =>
        sinkConfiguration.RestrictedToMinimumLevel = LogEventLevel.Warning;
// At last, don't forget to register the logger into the services
var loggerFactory = new LoggerFactory();
  .AddSerilog() // if you are not assigning the logger to Log.Logger, then you need to add your logger here.



Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (23)

Showing the top 5 NuGet packages that depend on Serilog.Sinks.RabbitMQ:

Package Downloads

Base classed used in Project in Core


A free library for ASP.NET Core 6+ Microservices development, with Model, Model Repository, Entity Framework Core and common Web Api features like CORS, Json serialization fixes, Swagger generation, JWT Authentication for simple and objective microservices development


Base classed used in UOB Project in Core


Package Description


OK Micro Service EndPoints.Web Package

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.0.2 1,099 5/13/2024
7.0.1 14,317 3/19/2024
7.0.0 374 3/18/2024
7.0.0-pre.44 4,348 2/9/2024
6.0.0 1,182,020 1/23/2021
6.0.0-pre 36,421 10/4/2020
3.0.6 583,797 9/12/2019
3.0.3 17,010 7/5/2019
3.0.0 18,795 4/12/2019
2.0.2 222,020 4/25/2018
2.0.1 132,732 4/18/2017
2.0.0 4,376 10/18/2016 7,459 4/19/2016 1,420 4/15/2016 1,570 1/27/2016 1,944 11/3/2015 1,462 10/29/2015 1,416 10/29/2015