简体   繁体   English

具有Application Insights的asp.net core 2记录器

[英]asp.net core 2 Logger with Application Insights

I have a asp.net core 2 application where i am trying to log traces using LoggerMessage extension methods.( https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/loggermessage ). 我有一个asp.net core 2应用程序,我试图在其中使用LoggerMessage扩展方法记录跟踪。( https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/logging/loggermessage )。 The default trace level is set to trace. 默认跟踪级别设置为跟踪。 I am logging Critical,Errors,Warnings and Information messages. 我正在记录严重,错误,警告和信息消息。 These appear on the console and the debug window. 这些出现在控制台和调试窗口上。 But are not reported to application insights. 但是没有报告给应用程序见解。

I have Added ".UseApplicationInsights()" to the web host builder and added the "_loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Trace);" 我已经将“ .UseApplicationInsights()”添加到了Web主机构建器,并添加了“ _loggerFactory.AddApplicationInsights(app.ApplicationServices,LogLevel.Trace);”。 to the startup. 到启动。 I have also ensure that the app insights key is set in the appsetting.json file. 我还确保在appsetting.json文件中设置了应用洞察力密钥。

"ApplicationInsights": { "InstrumentationKey": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX" }, Can someone help me with what am i missing? “ ApplicationInsights”:{“ InstrumentationKey”:“ XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX”},有人可以帮我解决我所缺少的吗?

SDK Version Microsoft.ApplicationInsights.AspNetCore - 2.1.1 Microsoft.AspNetCore.All - 2.0.5 SDK版本Microsoft.ApplicationInsights.AspNetCore-2.1.1 Microsoft.AspNetCore.All-2.0.5

Thanks @twinmind. 谢谢@twinmind。 That helped to resolve the issue. 这有助于解决问题。 But it was the other way around. 但这是另一回事。 We had to remove "AddApplicationInsights". 我们必须删除“ AddApplicationInsights”。 Removing "UseApplicationInsights" had not helped. 删除“ UseApplicationInsights”没有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Application Insights 开发人员模式在 ASP.NET 核心 3.1 中不起作用 - Application Insights Developer Mode not working in ASP.NET Core 3.1 来自 ASP.NET Core 身份的 Application Insights 用户 ID - Application Insights User ID from ASP.NET Core identity 记录器未显示在ASP.NET Core 2.1应用程序中 - Logger not showing in ASP.NET Core 2.1 Application ASP.NET Core MVC应用程序洞察在升级到.NET Core 1.1.1后停止工作 - ASP.NET Core MVC application insights stopped working after upgrade to .NET Core 1.1.1 ASP.NET Core - 默认记录器中的 Serilog - ASP.NET Core - Serilog in default the logger ASP.NET Core-记录器的多个实例 - ASP.NET Core - Multiple instances of Logger 如何从 ASP.NET Core 应用程序将应用程序洞察数据发布到 REST API 而不是 Azure? - How to post application insights data to REST API instead of Azure from ASP.NET Core application? ASP.NET Core 2.1 Web.API更改应用程序见解的日志记录检测键 - ASP.NET Core 2.1 Web.API change application insights instrumentation key for logging 未从 asp.net 核心 webapi 在 Application Insights 中打印日志 - Logs not getting printed in Application Insights from asp.net core webapi 如何将 Azure Application Insights for Asp.Net Core 5.0 配置为仅发送 4% 的请求和 100% 的异常? - How to configure Azure Application Insights for Asp.Net Core 5.0 to send only 4% of Requests and 100% of Exceptions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM