This is a gRPC Serilog Sink for Grafana's Loki Log Aggregator.
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
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();