我如何使用与NLOG Microsoft应用程序洞察(目标无法找到:“ApplicationInsights') [英] How do I use Microsoft Application Insights with NLog (Target cannot be found: 'ApplicationInsights')

查看:1758
本文介绍了我如何使用与NLOG Microsoft应用程序洞察(目标无法找到:“ApplicationInsights')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Microsoft应用程序解析我的Web应用程序。我使用的应用程序洞察的TraceListener的NuGet包记录。这工作完美。

I am using Microsoft Application Insights for my Web Application. I used the Application Insights TraceListener NuGet package for logging. That worked perfectly.

现在我想切换到NLOG。我加了 Microsoft.ApplicationInsights.NLogTarget 的NuGet包在我NLOG配置文件中添加了一个新的目标NLOG:

Now I would like to switch to NLog. I added the Microsoft.ApplicationInsights.NLogTarget NuGet package and added a new NLog target in my NLog configuration file:

<target name='ai' xsi:type='ApplicationInsights' />



NLOG抛出异常:

NLog throws an exception:

Target cannot be found: 'ApplicationInsights'

我也试过添加通过像这样的扩展组件:

I also tried adding the assembly via extensions like so:

<extensions>
    <add assembly="Microsoft.ApplicationInsights.NLogTarget" />
</extensions>    



但它也不能工作。

But it did not work either.

任何建议

推荐答案

解决方案:(感谢@nemesv的提示)

Solution: (thanks to @nemesv for the tip)

编程与添加

ConfigurationItemFactory.Default.Targets.RegisterDefinition(
    "ApplicationInsightsTarget", 
    typeof(Microsoft.ApplicationInsights.NLogTarget.ApplicationInsightsTarget)
);



and use it with

<target name='ai' xsi:type='ApplicationInsightsTarget' />

这篇关于我如何使用与NLOG Microsoft应用程序洞察(目标无法找到:“ApplicationInsights')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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