Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oleh-zheleznyak/c9329623698302a15a1ea5b51e9738e6 to your computer and use it in GitHub Desktop.
Save oleh-zheleznyak/c9329623698302a15a1ea5b51e9738e6 to your computer and use it in GitHub Desktop.
Serilog ApplicationInsights config file to register an operation id enricher from custom assembly
{
"Serilog": {
"Using": [ "YourCompany.YourComponent.YourProject", "Serilog.Sinks.Console", "Serilog.Sinks.File", "Serilog.Enrichers.Environment", "Serilog.Sinks.Elasticsearch" ],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Information"
}
},
"WriteTo": [
{
"Name": "Async",
"Args": {
"configure": [
{ "Name": "Console" },
{
"Name": "ApplicationInsights",
"Args": {
"restrictedToMinimumLevel": "Information",
"telemetryConverter": "YourCompany.YourComponent.YourProject.Serilog.OperationTelemetryConverter, YourCompany.YourComponent.YourProject"
}
}
]
}
}
],
"Enrich": [ "WithOperationId", "FromLogContext", "WithMachineName", "WithEnvironmentUserName", "WithThreadId" ],
"Properties": {
"Application": "YourCompany.YourComponent.YourProject"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment