From b15d0769ab96f019dae58a8a30c1cf93d0748307 Mon Sep 17 00:00:00 2001 From: Joseph Woodward Date: Mon, 7 Jan 2019 09:35:52 +0000 Subject: [PATCH 1/4] Update README.md --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f0460a..e906bd8 100644 --- a/README.md +++ b/README.md @@ -31,4 +31,15 @@ log.Error(exception); var position = new { Latitude = 25, Longitude = 134 }; var elapsedMs = 34; log.Information("Message processed {@Position} in {Elapsed:000} ms.", position, elapsedMs); -``` \ No newline at end of file +``` + +### Adding global labels + +Global labels can be added by implementing the `ILogLabelProvider` class: + +```csharp +public class GlobalLabelsDefinition : ILogLabelProvider { + + +} +``` From e125664902c10b4236acba5796bc7d55cc8a8cfe Mon Sep 17 00:00:00 2001 From: Joseph Woodward Date: Mon, 7 Jan 2019 09:37:31 +0000 Subject: [PATCH 2/4] Update README.md --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e906bd8..d221508 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,16 @@ log.Information("Message processed {@Position} in {Elapsed:000} ms.", position, Global labels can be added by implementing the `ILogLabelProvider` class: ```csharp -public class GlobalLabelsDefinition : ILogLabelProvider { - - +public class LogLabelProvider : ILogLabelProvider + { + public IList GetLabels() + { + return new List + { + new LokiLabel { Key = "app", Value = "demoapp" }, + new LokiLabel { Key = "environment", Value = "production" } + }; + } } + ``` From b70a5f5a4d458933777ebf02ddce29d5657e910b Mon Sep 17 00:00:00 2001 From: Joseph Woodward Date: Mon, 7 Jan 2019 09:39:14 +0000 Subject: [PATCH 3/4] Update README.md --- README.md | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d221508..2e0e04f 100644 --- a/README.md +++ b/README.md @@ -38,16 +38,25 @@ log.Information("Message processed {@Position} in {Elapsed:000} ms.", position, Global labels can be added by implementing the `ILogLabelProvider` class: ```csharp -public class LogLabelProvider : ILogLabelProvider - { - public IList GetLabels() +public class LogLabelProvider : ILogLabelProvider { + + public IList GetLabels() + { + return new List { - return new List - { - new LokiLabel { Key = "app", Value = "demoapp" }, - new LokiLabel { Key = "environment", Value = "production" } - }; - } + new LokiLabel { Key = "app", Value = "demoapp" }, + new LokiLabel { Key = "environment", Value = "production" } + }; + } + } +``` +This class can then be passed to the Loki sink when configuring it: +```csharp +var log = new LoggerConfiguration() + .MinimumLevel.Verbose() + .Enrich.FromLogContext() + .WriteTo.LokiHttp("http://localhost:3100/api/prom/push", new LogLabelProvider()) + .CreateLogger(); ``` From 8ecf214a7a3dcad7b5d9af59e2babb9012f084e8 Mon Sep 17 00:00:00 2001 From: Joseph Woodward Date: Mon, 7 Jan 2019 09:41:16 +0000 Subject: [PATCH 4/4] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 2e0e04f..d05c4d2 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ log.Information("Message processed {@Position} in {Elapsed:000} ms.", position, ### Adding global labels -Global labels can be added by implementing the `ILogLabelProvider` class: +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 { @@ -51,8 +51,6 @@ public class LogLabelProvider : ILogLabelProvider { } ``` -This class can then be passed to the Loki sink when configuring it: - ```csharp var log = new LoggerConfiguration() .MinimumLevel.Verbose()