Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 1.2 KB

README.md

File metadata and controls

40 lines (29 loc) · 1.2 KB

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