From dd8fd08eec1d54d63bcedc9b1a2c352adc62319d Mon Sep 17 00:00:00 2001 From: BiplovKC Date: Sun, 22 Jan 2023 18:18:31 +0100 Subject: [PATCH] Update README.md --- README.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 499bc77..b64ea27 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,32 @@ -# serilog-logging -Common middleware and serilog extensions. Ready to be injected and used +# Serilog Logging +

+ + [![NuGet](https://img.shields.io/nuget/v/Biplov.Serilog.svg)](https://www.nuget.org/packages/Biplov.Serilog/) + [![Downloads](https://img.shields.io/nuget/dt/Biplov.Serilog?color=brightgreen.svg)](https://www.nuget.org/packages/Biplov.Serilog/) + [![Stars](https://img.shields.io/github/stars/dotnet/BenchmarkDotNet?color=brightgreen)](https://github.com/biplovkc/serilog-logging/stargazers) + [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md) + +

+ +## How to use + +You should be registering serilog in your `Program.cs`. + +### Inside ConfigureServices method Invoke + +``` +services.RegisterSerilogLogger( + Configuration, // See [IConfiguration](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.configuration.iconfiguration?view=dotnet-plat-ext-7.0) + typeof(Program).Assembly.GetName().Version.ToString(), + "RequestPath like '/Account/Login%'", + "RequestPath like '/Account/Register%'", + "@l in ['Information'] and RequestPath like '%/_system/%'"); +``` + +### Inside Configure method add +``` +app.UseCorrelationIdMiddleware("MyCorrelationId"); // Defaults to CorrelationId if no value passed +app.UseSerilogRequestLogging(options => options.EnrichDiagnosticContext = HttpContextEnricher.HttpRequestEnricher); +``` +## Coming soon +Example project