Serilog.Sinks.Nats 1.1.1

Serilog sink for NATS messaging server

Install-Package Serilog.Sinks.Nats -Version 1.1.1
dotnet add package Serilog.Sinks.Nats --version 1.1.1
<PackageReference Include="Serilog.Sinks.Nats" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Sinks.Nats --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

serilog.sinks.nats

Serilog Sink for Nats

Installation

Using Nuget:

Install-Package Serilog.Sinks.Nats

Usage

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&lt;T&gt;.

using Serilog;
using Serilog.Formatting.Json;
using Serilog.Sinks.Nats;

public class Startup 
{
   private readonly IConfiguration _config;
   // ... 
   public IServiceProvider ConfigureServices(IServiceCollection services)
   {
      var config = new NatsConfiguration
      {
          host = _config["NATS_HOST"]
          // ...
      };

      Log.Logger = new LoggerConfiguration()
        .Enrich.FromLogContext()
        .WriteTo.Nats(config, new JsonFormatter())
        .CreateLogger();

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

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

References

serilog.sinks.nats

Serilog Sink for Nats

Installation

Using Nuget:

Install-Package Serilog.Sinks.Nats

Usage

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&lt;T&gt;.

using Serilog;
using Serilog.Formatting.Json;
using Serilog.Sinks.Nats;

public class Startup 
{
   private readonly IConfiguration _config;
   // ... 
   public IServiceProvider ConfigureServices(IServiceCollection services)
   {
      var config = new NatsConfiguration
      {
          host = _config["NATS_HOST"]
          // ...
      };

      Log.Logger = new LoggerConfiguration()
        .Enrich.FromLogContext()
        .WriteTo.Nats(config, new JsonFormatter())
        .CreateLogger();

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

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

References

Release Notes

Fixed a few bugs

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.1.1 917 1/28/2018
1.1.0 293 1/28/2018
1.0.3 223 1/28/2018
1.0.2 273 1/28/2018
1.0.1 282 1/28/2018
1.0.0 213 1/28/2018