Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oleh-zheleznyak/ed8b272259968a135d7c2e56537a300a to your computer and use it in GitHub Desktop.
Save oleh-zheleznyak/ed8b272259968a135d7c2e56537a300a to your computer and use it in GitHub Desktop.
Serilog for Application Insights logging extensions - extension method to enrich log events with OperationIdEnricher
using System;
using Serilog;
using Serilog.Configuration;
namespace YourCompany.YourService.YourProject.Serilog
{
public static class LoggingExtensions
{
public static LoggerConfiguration WithOperationId(this LoggerEnrichmentConfiguration enrichConfiguration)
{
if (enrichConfiguration is null) throw new ArgumentNullException(nameof(enrichConfiguration));
return enrichConfiguration.With<OperationIdEnricher>();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment