using Serilog.Configuration; using Serilog.Core; using Serilog.Events; using Serilog; namespace TelpoKafkaConsole.WebApi.Configs { public class ThreadInfoEnricher : ILogEventEnricher { public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("ThreadId", Thread.CurrentThread.ManagedThreadId)); } } public static class EnricherExtensions { public static LoggerConfiguration WithThreadInfo(this LoggerEnrichmentConfiguration enrich) { if (enrich == null) throw new ArgumentNullException(nameof(enrich)); return enrich.With(); } } }