Author : MD TAREQ HASSAN

Enricher

Serilog project provides:

Other enrichers:

Installation

Install-Package Serilog.Enrichers.Environment
Install-Package Serilog.Enrichers.Process
Install-Package Serilog.Enrichers.Thread
Install-Package Serilog.Enrichers.AspnetcoreHttpcontext
Install-Package Serilog.Exceptions

Using Enricher

var configuration = new ConfigurationBuilder()
   .AddJsonFile("appsettings.json")
   .Build();

Log.Logger = new LoggerConfiguration()
    .ReadFrom.Configuration(configuration)
    .Enrich.WithThreadId()
    .Enrich.FromLogContext()
    .CreateLogger();

ILogEventEnricher

Log.Logger = new LoggerConfiguraition()  
     .Enrich.FromLogContext()
     // ...
     
private readonly ILogger _log = Log.ForContext<HomeController>();