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.

32 satır
886B

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