Created
August 4, 2019 13:57
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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