All Projects → lyng-dev → serilog-sinks-rabbitmq

lyng-dev / serilog-sinks-rabbitmq

Licence: Apache-2.0 license
Serilog Sink for RabbitMq

Programming Languages

C#
18002 projects
powershell
5483 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to serilog-sinks-rabbitmq

serilog-sinks-slackclient
Slack Sink for Serilog
Stars: ✭ 24 (-51.02%)
Mutual labels:  serilog-sink, serilog
serilog-sinks-seq
A Serilog sink that writes events to the Seq structured log server
Stars: ✭ 132 (+169.39%)
Mutual labels:  serilog-sink, serilog
serilog-sinks-xamarin
A Serilog sink that writes events to Xamarin mobile targets
Stars: ✭ 46 (-6.12%)
Mutual labels:  serilog-sink, serilog
PoShLog
🔩 PoShLog is PowerShell cross-platform logging module. It allows you to log structured event data into console, file and much more places easily. It's built upon great C# logging library Serilog - https://serilog.net/
Stars: ✭ 108 (+120.41%)
Mutual labels:  serilog-sink, serilog
Serilog
Simple .NET logging with fully-structured events
Stars: ✭ 5,000 (+10104.08%)
Mutual labels:  serilog
Serilog.Sinks.Postgresql.Alternative
Serilog.Sinks.Postgresql.Alternative is a library to save logging information from https://github.com/serilog/serilog to https://www.postgresql.org/.
Stars: ✭ 29 (-40.82%)
Mutual labels:  serilog
CleanArchitecture-Template
This is a solution template for Clean Architecture and CQRS implementation with ASP.NET Core.
Stars: ✭ 60 (+22.45%)
Mutual labels:  serilog
Serilog.Sinks.MicrosoftTeams.Alternative
Serilog.Sinks.MicrosoftTeams.Alternative is a library to save logging information from Serilog to Microsoft Teams.
Stars: ✭ 21 (-57.14%)
Mutual labels:  serilog
serilog-sinks-browserhttp
Serilog sink for client-side Blazor, with matching ASP.NET Core server relay
Stars: ✭ 36 (-26.53%)
Mutual labels:  serilog
Kodkod
https://github.com/alirizaadiyahsi/Nucleus Web API layered architecture startup template with ASP.NET Core 2.1, EF Core 2.1 and Vue Client
Stars: ✭ 45 (-8.16%)
Mutual labels:  serilog
serilog-sinks-grafana-loki
A Serilog sink sending log events to Grafana Loki
Stars: ✭ 55 (+12.24%)
Mutual labels:  serilog
ASPNETcoreAngularJWT
Angular in ASP.NET Core with JWT solution by systemjs
Stars: ✭ 48 (-2.04%)
Mutual labels:  serilog
serilog-sinks-richtextbox
A Serilog sink that writes log events to a WPF RichTextBox control with colors and theme support
Stars: ✭ 48 (-2.04%)
Mutual labels:  serilog
seq-forwarder
Local collection and reliable forwarding of log data to Seq
Stars: ✭ 43 (-12.24%)
Mutual labels:  serilog
serilog-sinks-sentry
A Sentry sink for Serilog
Stars: ✭ 34 (-30.61%)
Mutual labels:  serilog
Sitko.Core
Sitko.Core is a set of libraries to help build .NET Core applications fast
Stars: ✭ 46 (-6.12%)
Mutual labels:  serilog
Akka.Logger.Serilog
Akka.NET logging integration for Serilog library
Stars: ✭ 22 (-55.1%)
Mutual labels:  serilog
serilog-settings-reloader
Adds feature to completely reload serilog settings. Also contains switchable ILogger implementation.
Stars: ✭ 16 (-67.35%)
Mutual labels:  serilog
resharper-structured-logging
An extension for ReSharper and Rider that highlights structured logging templates and contains some useful analyzers
Stars: ✭ 117 (+138.78%)
Mutual labels:  serilog
arcus.observability
Observability with Microsoft Azure in a breeze.
Stars: ✭ 24 (-51.02%)
Mutual labels:  serilog

serilog-sinks-rabbitmq

Build Status Gitter

Maintainers Wanted

This project is looking for maintainers. No new features or releases are scheduled. If you want to become a steward for this repository, please open an issue, and let us know.

Purpose

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.

Versioning

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

Dependencies

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.1.0

Installation

Using Nuget:

Install-Package Serilog.Sinks.RabbitMQ

Version 2.0.0 configuration

To use with ILoggerFactory via dependency injection, add the following to ConfigureServices in your Startup class. See the logging documentation for specific help on using the ILoggerFactory and ILogger<T>.

using Serilog;
using Serilog.Formatting.Json;
using Serilog.Sinks.RabbitMQ;
using Serilog.Sinks.RabbitMQ.Sinks.RabbitMQ;

public class Startup 
{
   private readonly IConfiguration _config;
   // ... 
   public IServiceProvider ConfigureServices(IServiceCollection services)
   {
      var config = new RabbitMQConfiguration
      {
          Hostname = _config["RABBITMQ_HOST"],
          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(config, new JsonFormatter())
        .CreateLogger();

      var loggerFactory = new LoggerFactory();
      loggerFactory
        .AddSerilog()
        .AddConsole(LogLevel.Information);

      services.AddSingleton<ILoggerFactory>(loggerFactory);
   }
   // ...
}

Version 3.0.0 configuration

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

Log.Logger = new LoggerConfiguration()
    .Enrich.FromLogContext()
    .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["RABBITMQ_HOSTNAMES"]) {
            clientConfiguration.Hostnames.Add(hostname);
        }

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

      services.AddSingleton<ILoggerFactory>(loggerFactory);

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].