You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 satır
765B

  1. using Serilog.Configuration;
  2. using Serilog.Core;
  3. using Serilog.Events;
  4. using Serilog;
  5. namespace TelpoKafkaConsole.WebApi.Configs
  6. {
  7. public class ThreadInfoEnricher : ILogEventEnricher
  8. {
  9. public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
  10. {
  11. logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("ThreadId", Thread.CurrentThread.ManagedThreadId));
  12. }
  13. }
  14. public static class EnricherExtensions
  15. {
  16. public static LoggerConfiguration WithThreadInfo(this LoggerEnrichmentConfiguration enrich)
  17. {
  18. if (enrich == null)
  19. throw new ArgumentNullException(nameof(enrich));
  20. return enrich.With<ThreadInfoEnricher>();
  21. }
  22. }
  23. }