Umbraco + AppInsights
# help-with-umbraco
c
Does anyone have this fully working, including Exceptions being logged? We seem to be hitting a scenario whereby the actual Exception details are not being sent to AppInsights (but the 500 response is being logged).
d
Hi there! We are doing just that! Let me find some samples that I can share with you
Initially we thought that we could just integrate it into serilog, but in practice that turned out not to be enough. We did the following things: In startup.cs, we added the following line:
Copy code
csharp
services.AddApplicationInsightsTelemetry();
We have these packages installed: - Serilog.Sinks.ApplicationInsights - Microsoft.ApplicationInsights.AspNetCore In our appsettings, we have the following configurations:
Copy code
json
{
    "Serilog": {
        "Using": [ "Serilog.Sinks.ApplicationInsights" ],
        "WriteTo": [
            {
                "Name": "ApplicationInsights",
                "Args": {
                    "connectionString": "[value in secrets]",
                    "telemetryConverter": "Serilog.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"
                }
            }
        ]
    },
    "ApplicationInsights": {
        "ConnectionString": "[value in secrets]"
    }
}
That was all that we needed to get it to work
To be honest, I'm not sure if the serilog extension is actually doing anything, but supposedly it sends traces to application insights.
j
Just wanted to add we have this additional 2nd line in our setup:
Copy code
csharp
services.AddApplicationInsightsTelemetry();

services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module, o) => { module. EnableSqlCommandTextInstrumentation = true; });
Which enables it to log the full sql commands used on db calls - helps a lot with debugging 🙂
c
This is all about to come to a head with moving to OTEL in AppInsights....
We are specifically opting out of sql logging... as .. last count it was responsible for about $650 a month in logs.. heh
what we're observing, without the serilog sink part is that we have the 500s logged, but no actual exception details that caused them.
According to the docs, shouldn't need that using line..
OK, so what I don't like about this.. is we have 2 instances of TelemetryClient.. one used by AppInsights, and one used by serilog
190 Views