Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwoodward committed Jan 7, 2019
2 parents a1c8abd + 8ecf214 commit 0edbb06
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,30 @@ log.Error(exception);
var position = new { Latitude = 25, Longitude = 134 };
var elapsedMs = 34;
log.Information("Message processed {@Position} in {Elapsed:000} ms.", position, elapsedMs);
```
```

### Adding global labels

Global labels can be added by implementing the `ILogLabelProvider` class and passing the implementation to your Serilog Loki Sink configuration:

```csharp
public class LogLabelProvider : ILogLabelProvider {

public IList<LokiLabel> GetLabels()
{
return new List<LokiLabel>
{
new LokiLabel { Key = "app", Value = "demoapp" },
new LokiLabel { Key = "environment", Value = "production" }
};
}

}
```
```csharp
var log = new LoggerConfiguration()
.MinimumLevel.Verbose()
.Enrich.FromLogContext()
.WriteTo.LokiHttp("http://localhost:3100/api/prom/push", new LogLabelProvider())
.CreateLogger();
```

0 comments on commit 0edbb06

Please sign in to comment.