Skip to content

fvoncina/Serilog.Sinks.Loki.gRCP

Repository files navigation

Serilog.Sinks.Loki.gRpc

This is a gRPC Serilog Sink for Grafana's Loki Log Aggregator.

Actions Status

Installation

The Serilog.Sinks.Loki.gRPC NuGet package can be found here. Alternatively you can install it via one of the following commands below:

NuGet command:

Install-Package Serilog.Sinks.Loki.gRPC

.NET Core CLI:

dotnet add package Serilog.Sinks.Loki.gRPC

Usage

Log.Logger = new LoggerConfiguration()
        .MinimumLevel.Information()
        .Enrich.FromLogContext()
        .WriteTo.LokigRPC("localhost:9095")
        .CreateLogger();

var exception = new {Message = ex.Message, StackTrace = ex.StackTrace};
Log.Error(exception);

var position = new { Latitude = 25, Longitude = 134 };
var elapsedMs = 34;
Log.Information("Message processed {@Position} in {Elapsed:000} ms.", position, elapsedMs);

Log.CloseAndFlush();

Inspiration

Releases

No releases published

Packages

No packages published

Languages