You should be registering serilog in your Program.cs
.
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/%'");
app.UseCorrelationIdMiddleware("MyCorrelationId"); // Defaults to CorrelationId if no value passed
app.UseSerilogRequestLogging(options => options.EnrichDiagnosticContext = HttpContextEnricher.HttpRequestEnricher);
Example project can be found in example folder You can run it by running following docker command inside the example folder:
docker-compose up --build
This will run following services
Service | Url |
---|---|
API | http://localhost:5000 |
Seq | http://localhost:5341 |
For more info check: https://biplov.dev/enriching-serilog-log-entries