A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/daghb/serilog.sinks.nats below:

daghb/serilog.sinks.nats: Serilog sink for the NATS messaging server

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.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);
   }
   // ...
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4