Skip to content

Instantly share code, notes, and snippets.

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