无法获得Application Insights以显示调试遥测 [英] Unable to get Application Insights to show debugging telemetry

查看:156
本文介绍了无法获得Application Insights以显示调试遥测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Application Insights完全陌生,可悲的是,整整一整天我一直无法使它正常工作.我尝试使用以下代码:

I am a total noob with Application Insights, and sadly for a whole day of trying I have been unable to get it working at all. I tried with the following code:

this.telemetryClient = new TelemetryClient(TelemetryConfiguration.CreateDefault());
this.telemetryClient.TrackTrace($"Test", Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Warning);

但是,当我转到应用程序洞察"窗口并显示当前调试会话中的所有遥测时,没有任何日志记录.一位用户说缺少ApplicationInsights.config文件(空的文件可以很好地进行调试),我创建了一个文件,但它什么也没改变.

But when I go to the application insights window and show all telemetry from the current debugging session there is nothing logged. One user said an ApplicationInsights.config file is missing (and that an empty one would do fine for debugging), I created one but it changed nothing.

然后,我尝试了我能找到的最简单的控制台应用程序- https://docs.microsoft.com/zh-CN/azure/azure-monitor/app/console .我没有工具密钥,在我今天阅读的数百个论坛中,如果将其保留为空白,它仍将出现在调试遥测中. las,Application Insights还是一无所有.

Then I tried the simplest console app I could find - https://docs.microsoft.com/en-us/azure/azure-monitor/app/console . I don't have an instrumentation key, and from the hundreds of forums I read today, if you leave it blank it should still appear in the debugging telemetry. Alas, still nothing in Application Insights.

如何使它正常工作?当我被问到调试遥测"时,我只想在Visual Studio Application Insights窗口中看到一条跟踪消息.

How can I get it working? I just want to see a single Trace message in the Visual Studio Application Insights window when queried for "debugging telemetry".

推荐答案

我过去一直在研究这些东西以及它通常的工作方式,该扩展试图找出它是否应该监视调试输出,并且如果它不能识别项目类型,则我们什么也不做(避免在不需要时在调试器中执行主要工作).在这种情况下,控制台应用程序不是受支持的已知"项目类型.

I used to work on this stuff and the way it generally works, the extension tries to figure out if it should watch for debug output, and if it doesn't recognize the project type, we do nothing (to avoid doign work in the debugger when we don't need to). in this case, console apps aren't a "known" supported project type.

IIRC,要获取调试输出,我相信您需要做2件事,其中您已经完成1:

IIRC, to get debug output I believe you need to do 2 things, of which you've done 1:

1)在该项目的根目录下添加一个ApplicationInsights.config文件

1) add an ApplicationInsights.config file at the root of that project

2)将应用程序洞察资源ID添加到csproj:

2) add an application insight resource id to to the csproj:

 <ApplicationInsightsResourceId>/subscriptions/abc</ApplicationInsightsResourceId>

我什至不认为资源ID甚至必须是有效的,但是如果资源ID甚至更好,则因为其他事情可能会点亮,例如异常codelens,指向门户网站的各种链接/等,

i don't think the resource id even needs to be valid, but if it does even better, because then other things can light up, like exceptions codelens, various links to the portal/etc.

您只需要做#2吗?

认为,如果您执行上述操作并重新启动vs/reload解决方案,则应该看到调试器集成尝试在调试器启动时开始工作. (过去!)

i think that if you do the above and restart vs/reload the solution, you should see the debugger integration try to do work when the debugger starts. (it used to!)

这篇关于无法获得Application Insights以显示调试遥测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆