serilog-contrib / serilog-sinks-applicationinsights

A Serilog sink that writes events to Microsoft Azure Application Insights
Apache License 2.0
220 stars 71 forks source link

Configuration documentation for pre-Core Asp.Net project #205

Closed jsodeman closed 2 years ago

jsodeman commented 2 years ago

I'm trying to set this sink up in some older .Net 4.7 projects and every example I can find online is for Core. The current Serilog setup in being done in Global.asax and therefore lacks appsetting.json, HostBuilder, services, etc.

I think it would be helpful to at least have a link to an example in the README. (And if anyone can point me in the right direction I would appreciate that too)

jsodeman commented 2 years ago

In case someone else comes looking for this, for ASP.NET 4.8 or 4.7 it's the same as the example for ASP.NET CORE

.WriteTo.ApplicationInsights(TelemetryConfiguration.Active, TelemetryConverter.Traces)

You can put that in your global.asax or wherever you create your logger. The TelemetryConfiguration information is built into Azure, you just need to configure Application Insights for .Net instrumentation in Azure.