[英]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.