Plinth.Logging.NLog.AppInsights 1.5.0-b88.7a7c20cd

Prefix Reserved
This is a prerelease version of Plinth.Logging.NLog.AppInsights.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Plinth.Logging.NLog.AppInsights --version 1.5.0-b88.7a7c20cd
                    
NuGet\Install-Package Plinth.Logging.NLog.AppInsights -Version 1.5.0-b88.7a7c20cd
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Plinth.Logging.NLog.AppInsights" Version="1.5.0-b88.7a7c20cd" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Plinth.Logging.NLog.AppInsights" Version="1.5.0-b88.7a7c20cd" />
                    
Directory.Packages.props
<PackageReference Include="Plinth.Logging.NLog.AppInsights" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Plinth.Logging.NLog.AppInsights --version 1.5.0-b88.7a7c20cd
                    
#r "nuget: Plinth.Logging.NLog.AppInsights, 1.5.0-b88.7a7c20cd"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Plinth.Logging.NLog.AppInsights@1.5.0-b88.7a7c20cd
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Plinth.Logging.NLog.AppInsights&version=1.5.0-b88.7a7c20cd&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Plinth.Logging.NLog.AppInsights&version=1.5.0-b88.7a7c20cd&prerelease
                    
Install as a Cake Tool

README

Plinth.Logging.NLog.AppInsights

Integration allowing Plinth and NLog to record telemetry and logs to Azure Application Insights

1. Add this to your NLog.config under the <nlog> tag

  <extensions>
    <add assembly="Plinth.Logging.NLog.AppInsights" prefix="plinthAI" />
  </extensions>

2. Then create the target

  <targets>
    <target xsi:type="plinthAI.AppInsightsTarget" name="aiTarget">
      <connectionString>{from-Azure-Portal}</connectionString>
      <cloudRoleName>testRole1</cloudRoleName>
      <cloudRoleInstance>serverA</cloudRoleInstance>
      <maxLength>25000</maxLength>
    </target>
  </targets>
  • 👉 Do not wrap this in an async wrapper. It will break the context and metadata.
  • cloudRoleName and cloudRoleInstance are optional, and will have reasonable defaults if not specified
  • Cloud Role Name is typically the application name
  • Cloud Role Instance is typically the machine name
  • The maxLength field is optional, and defaults to 25000 characters
  • 👉 Using a connection string is preferred. <instrumentationKey> is supported but deprecated and will stop working in March 2025

3. Reference the target in a logger rule

  <rules>
    <logger name="*" minlevel="Debug" writeTo="aiTarget" />
  </rules>

4. Initialize telemetry in Startup

  services.AddPlinthAppInsightsTelemetry(cfg => 
  {
      cfg.CloudRoleName = "MyApp";
      cfg.DisabledPrefixes.Add("/health");
  });

👉 The lambda is optional and only necessary if setting hardcoded configuration

Configurations Options are

  • ConnectionString: If not setting via environment variable or NLog.config
  • DisabledPrefixes: A blacklist of url prefixes to disable Request Telemetry. Example: "/favicon.ico"
  • EnabledPrefixes: A whitelist of url prefixes to enable Request Telemetry. This is null by default. If a list of prefixes is specified, only requests which match will have request telemetry. If there is a conflict between this and DisabledPrefixes, the preference is to disable telemetry.
  • CaptureSqlCommandText: Set to true to have SQL Dependency Telemetry capture the SQL command text sent to the database. Defaults to false.
  • CloudRoleName: See next section
  • CloudRoleInstance: See next section

5. Application Insights Configuration Settings

Values are applied in this order of precedence

  • Connection String (get this from the Azure Portal)

    1. Hardcoded parameter passed in Startup.cs (does not apply to NLog logs)
    2. NLog.config <connectionString>
    3. Environment variable: APPLICATIONINSIGHTS_CONNECTION_STRING
    4. (Obsolete): NLog.config <instrumentationKey>
    5. (Obsolete): Environment variable APPINSIGHTS_INSTRUMENTATIONKEY
  • Cloud Role Name

    1. Hardcoded parameter passed in Startup.cs (does not apply to NLog logs)
    2. NLog.config <cloudRoleName>
    3. Environment variable: APPLICATIONINSIGHTS_CLOUD_ROLENAME
  • Cloud Role Instance

    1. Hardcoded parameter passed in Startup.cs (does not apply to NLog logs)
    2. NLog.config <cloudRoleInstance>
    3. Environment variable: APPLICATIONINSIGHTS_CLOUD_ROLEINSTANCE
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.7.2 226 3/16/2025
1.7.1 185 12/12/2024
1.7.0 216 11/12/2024
1.6.6 141 11/8/2024
1.6.5 1,854 8/31/2024
1.6.4 105 8/2/2024
1.6.3 335 5/15/2024
1.6.2 236 2/16/2024
1.6.1 3,189 1/5/2024
1.6.0 332 11/30/2023
1.5.10-b186.aca976b4 91 11/30/2023
1.5.9 156 11/29/2023
1.5.9-b174.64153841 101 11/23/2023
1.5.9-b172.dfc6e7bd 86 11/17/2023
1.5.9-b171.4e2b92e2 101 11/4/2023
1.5.8 188 10/23/2023
1.5.7 6,752 7/31/2023
1.5.6 5,154 7/13/2023
1.5.5 232 6/29/2023
1.5.4 621 3/7/2023
1.5.3 306 3/3/2023
1.5.2 557 1/11/2023
1.5.2-b92.7c961f5f 165 1/11/2023
1.5.0 419 11/9/2022
1.5.0-b88.7a7c20cd 142 11/9/2022
1.4.7 3,149 10/20/2022
1.4.6 623 10/17/2022
1.4.5 751 10/1/2022
1.4.4 529 8/16/2022
1.4.3 546 8/2/2022
1.4.2 718 7/19/2022
1.4.2-b80.7fdbfd04 176 7/19/2022
1.4.2-b74.acaf86f5 164 6/15/2022
1.4.1 537 6/13/2022
1.4.0 550 6/6/2022
1.3.8 1,220 4/12/2022
1.3.7 611 3/21/2022
1.3.6 607 3/17/2022
1.3.6-b67.ca5053f3 183 3/16/2022
1.3.6-b66.4a9683e6 179 3/16/2022
1.3.5 646 2/23/2022
1.3.4 958 1/20/2022
1.3.3 391 12/29/2021
1.3.2 562 12/11/2021
1.3.1 425 11/12/2021
1.3.0 444 11/8/2021
1.2.3 1,633 9/22/2021
1.2.2 462 8/20/2021
1.2.1 448 8/5/2021
1.2.0 509 8/1/2021
1.2.0-b37.a54030b9 214 6/24/2021
1.1.6 3,153 3/22/2021
1.1.5 659 3/9/2021
1.1.4 552 2/27/2021
1.1.3 551 2/17/2021
1.1.2 579 2/12/2021
1.1.1 585 2/1/2021
1.1.0 601 12/16/2020
1.1.0-b27.b66c309b 356 11/15/2020
1.0.12 774 10/18/2020
1.0.11 674 10/6/2020

net7.0 support and removed netcoreapp3.1