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