Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Niels Swimberghe 22 posts 105 karma points c-trib
    Oct 11, 2022 @ 04:40
    Niels Swimberghe
    0

    Exceptions not recorded in Azure Application Insights

    I added Azure Application Insights (AI) to my Umbraco 10 website:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddUmbraco(env, config)
            .AddBackOffice()
            .AddWebsite()
            .AddComposers()
            .AddAzureBlobMediaFileSystem()
            .Build();
    
        services.AddApplicationInsightsTelemetry();
    }
    

    I can see exceptions being logged in Umbraco using the Log Viewer, but those exceptions are not being recorded in AI.

    Any idea what I should do to get them into AI?

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Oct 11, 2022 @ 09:10
    Matthew Wise
    0

    Hi Niels,

    I have added services.AddApplicationInsightsTelemetry(); before services.AddUmbraco(_env, _config)

    I also set the Serilog sink via the appsettings.json

    "Serilog": {
            "MinimumLevel": {
                "Default": "Information",
                "Override": {
                    "Microsoft": "Warning",
                    "SixLabors.ImageSharp.Web.Middleware": "Warning",
                    "Microsoft.Hosting.Lifetime": "Information",
                    "System": "Warning"
                }
            },
            "Enrich": [
                "FromLogContext",
                "WithEnvironmentName"
            ],
            "WriteTo": [
                {
                    "Name": "ApplicationInsights",
                    "Args": {
                        "telemetryConverter": "Serilog.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"
                    }
                }
            ]
        },
        "ApplicationInsights": {
            "EnableAdaptiveSampling": false,
            "EnablePerformanceCounterCollectionModule": false
        },
    

    Hope this helps,

    Matt

  • Niels Swimberghe 22 posts 105 karma points c-trib
    Oct 11, 2022 @ 17:11
    Niels Swimberghe
    0

    I'll try putting services.AddApplicationInsightsTelemetry(); in front of adding Umbraco. I put it in this order because that's what the docs for Cloud say.

    I do have the Serilog sink already setup. I'll get back to you after collecting some more telemetry.

  • Niels Swimberghe 22 posts 105 karma points c-trib
    Oct 12, 2022 @ 00:59
    Niels Swimberghe
    0

    Unfortunately, an exception was still logged in Umbraco but not tracked in AI:

    System.FormatException: Input string was not in a correct format.
       at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
       at System.Convert.ToDecimal(String value, IFormatProvider provider)
       at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
       at SixLabors.ImageSharp.Web.Commands.Converters.IntegralNumberConverter`1.ConvertFrom(CommandParser parser, CultureInfo culture, String value, Type propertyType)
       at SixLabors.ImageSharp.Web.Processors.QualityWebProcessor.Process(FormattedImage image, ILogger logger, CommandCollection commands, CommandParser parser, CultureInfo culture)
       at SixLabors.ImageSharp.Web.Processors.WebProcessingExtensions.Process(FormattedImage source, ILogger logger, IReadOnlyList`1 processors, CommandCollection commands, CommandParser parser, CultureInfo culture)
       at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.ProcessRequestAsync(HttpContext httpContext, IImageResolver sourceImageResolver, ImageContext imageContext, CommandCollection commands, Boolean retry)
       at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.ProcessRequestAsync(HttpContext httpContext, IImageResolver sourceImageResolver, ImageContext imageContext, CommandCollection commands, Boolean retry)
       at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
       at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 121
       at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
    --- End of stack trace from previous location ---
       at Umbraco.Cms.Web.Common.Middleware.PreviewAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
    --- End of stack trace from previous location ---
       at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestLoggingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
    
  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Oct 11, 2022 @ 10:55
    Jeavon Leopold
    0

    In addition to the configuration Matthew has posted you will need to install the Serilog Sink package - https://github.com/serilog-contrib/serilog-sinks-applicationinsights

    And ensure you have the environment variable APPLICATIONINSIGHTS_CONNECTION_STRING - https://github.com/serilog-contrib/serilog-sinks-applicationinsights#configuring-with-readfromconfiguration

  • Niels Swimberghe 22 posts 105 karma points c-trib
    Oct 11, 2022 @ 17:11
    Niels Swimberghe
    0

    I have this configured already, thank you!

  • Preben Neirijnck 3 posts 73 karma points
    Oct 24, 2023 @ 09:15
    Preben Neirijnck
    0

    Hello Niels, Did you find a solution to this problem - I'm having the same issue..

  • Niels Swimberghe 22 posts 105 karma points c-trib
    Oct 24, 2023 @ 17:57
    Niels Swimberghe
    0

    No, it's been a while, but I don't think so.

  • Alex 8 posts 131 karma points
    Nov 08, 2023 @ 15:45
    Alex
    1

    Hi all,

    I'm experiencing the same issue. I've opened a ticket with Umbraco Support, but thought I would share what I've seen here as well if someone else can figure out the root cause. Essentially the default setup is working in v9, but not in v10+.

    https://github.com/vipervf1/umb-app-insights-debug

    The biggest callout is that in version 9, the logger has multiple outputs where in v10 it is just serilog.

    Version 9 Injected ILogger

    Version 10 Injected ILogger

    This explains the drop off in AppTraces going to Application Insights, but I'm not sure if this is the cause of AppExceptions falling off as well.

  • Chad 66 posts 130 karma points c-trib
    Sep 02, 2024 @ 23:47
    Chad
    0

    We're running into this issue as well. In our case, we do not want all of Umbraco logs headed to AppInsights (as the volume of logging becomes expensive so we're sending it elsewhere) but we're finding that the 500 is logged in AI, but not the actual exception that caused it.

Please Sign in or register to post replies

Write your reply to:

Draft