Copied to clipboard

Flag this post as spam?

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


  • Sean Thorne 1 post 76 karma points c-trib
    Apr 18, 2019 @ 14:23
    Sean Thorne
    0

    Serilog to App Insights?

    Hey,

    Fairly new to Umbraco and am using version 8, can anyone help me / push me in the right direction on how to configure Application Insights to work with Umbraco's internal Logging.

    I'd like to be able to see all Logs that created pushed through to app insights

  • Dave de Moel 122 posts 574 karma points c-trib
    Apr 19, 2019 @ 11:43
    Dave de Moel
    0

    To push Umbraco log messages from serilog to App Insights you need to use the correct "sink".

    You can find the package for the sink here: https://www.nuget.org/packages/Serilog.Sinks.ApplicationInsights/

    And the documentation here: https://github.com/serilog/serilog-sinks-applicationinsights

  • Pankaj Nainwal 4 posts 24 karma points
    Jun 03, 2020 @ 17:54
    Pankaj Nainwal
    0

    Hi Sean, were you able to implement this? Can you post some learnings.

  • Mario Lopez 168 posts 952 karma points MVP 3x c-trib
    Jun 17, 2020 @ 06:53
    Mario Lopez
    1

    You need to install the nuget that Dave said. Then you have to configure it in the '~/config/serilog.user.config' as:

      <add key="serilog:using:ApplicationInsights" value="Serilog.Sinks.ApplicationInsights"/>
      <add key="serilog:write-to:ApplicationInsights.telemetryConverter" value="Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"/>
      <add key="serilog:minimum-level:override:Microsoft" value="Warning" />
    

    Check the configuration of the package and try to 'translate' it to the XML configuration if you need something else, but that should give you a start ;)

  • Daniel Bardi 927 posts 2562 karma points
    Nov 07, 2022 @ 17:19
    Daniel Bardi
    0

    I added the settings to my serilog.user.config and now get the following error:

    Invalid cast from 'System.String' to 'Serilog.Sinks.ApplicationInsights.TelemetryConverters.ITelemetryConverter'.

    .. Any assistance would be appreciated.

  • Keith Lawrence 8 posts 82 karma points
    Dec 06, 2022 @ 13:36
    Keith Lawrence
    1

    I got this error after upgrading a working version of Serilog.Sinks.ApplicationInsights to v4.0.0 - rolling back to 3.1.0 fixed the issue.

  • Hasan Habib 8 posts 88 karma points
    Oct 30, 2023 @ 05:45
    Hasan Habib
    0
      <add key="serilog:write-to:ApplicationInsights.telemetryConverter" value="Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"/>
    

    This line keeps giving me error: Invalid cast from 'System.String' to 'Serilog.Sinks.ApplicationInsights.TelemetryConverters.ITelemetryConverter'.

    Downgrading the version to 3.1.0 but nothing happens.

  • Keith Lawrence 8 posts 82 karma points
    Oct 30, 2023 @ 08:54
    Keith Lawrence
    0

    Odd - it works for me as per the following on 3.1.0

    <!-- The following three keys are from https://our.umbraco.com/forum/umbraco-8/96895-serilog-to-app-insights --> <add key="serilog:using:ApplicationInsights" value="Serilog.Sinks.ApplicationInsights"/> <add key="serilog:write-to:ApplicationInsights.telemetryConverter" value="Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"/> <add key="serilog:minimum-level:override:Microsoft" value="Warning" />

  • Gavin Williams 47 posts 220 karma points
    Nov 13, 2020 @ 13:19
    Gavin Williams
    0

    Hi Sean. Were you able to get this to work? For example, how did you configure the instrumentation key and/or connection string so it knows which appinsights instance to write to?

  • Frederik T 234 posts 345 karma points
    Sep 08, 2023 @ 09:58
    Frederik T
    0

    In case anyone else stumbles over this from Google: I added application insights to an existing Umbraco 8.18 installation, and a combination of solutions worked:

    Using the manual installation guide here (automatic didnt work): https://learn.microsoft.com/en-gb/azure/azure-monitor/app/asp-net#add-application-insights-manually

    Then Mario Lopez' solution with serilog in the config, and lastly Keith Lawrence with serilog sink version tip (saved me a couple of hours!).

    Shout out to this guy as well: https://www.bmck.au/posts/2021/umbraco-logging-to-azure-application-insights

Please Sign in or register to post replies

Write your reply to:

Draft