简体   繁体   English

NLog扩展以编程方式添加程序集

[英]NLog extensions add assembly programmatically

I am using nlog v3 and I cannot figure out the way to do programatically what 我正在使用nlog v3,我无法弄清楚以编程方式做什么的方式

  <nlog>
    <extensions>
      <add assembly="NLog.MongoDB" />
    </extensions>...

does. 确实。 I found one answer on old Nlog forums, that could've helped, but it was for v1 and v2 and these classes are no longer there. 我在旧的Nlog论坛上找到了一个答案,这可能有所帮助,但它适用于v1和v2,这些类不再存在。 Anybody knows how to do it in code? 有谁知道如何在代码中做到这一点?

This should do it: 这应该这样做:

var assembly = Assembly.Load("NLog.MongoDB");
NLog.Config.ConfigurationItemFactory.Default.RegisterItemsFromAssembly(assembly);

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM