gpt4 book ai didi

macos - 手动连接应用程序洞察

转载 作者:行者123 更新时间:2023-12-03 03:00:50 25 4
gpt4 key购买 nike

我正在使用 VS for macOS 社区开发一个 asp.net core 站点,不幸的是没有“添加应用程序见解遥测”。

这使得 https://learn.microsoft.com/en-us/azure/application-insights/app-insights-asp-net-core有点不太有帮助...

那么,我如何手动连接它?

最佳答案

您可以手动进行更改。有 3 件事要做。

  1. 编辑您的 .csproj,添加此行以引入 ApplicationInsights。

<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />

  • 修改 Program.cs 以包含对 UseApplicationInsights() 的调用,如下所示。

    public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
    .UseStartup<Startup>()
    .UseApplicationInsights()
    .Build();

  • 添加您的检测 key - 作为上面 UseApplicationInsights() 的参数或在 appsettings.json 中

    {
    "ApplicationInsights": {
    "InstrumentationKey": "11111111-2222-3333-4444-555555555555"
    }
    }

  • 现在运行应用程序,遥测数据将开始流向 Application Insights,

    维基百科中也描述了这些步骤: https://github.com/Microsoft/ApplicationInsights-aspnetcore/wiki/StartingDoc

    关于macos - 手动连接应用程序洞察,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49142164/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com