Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NLog extensions add assembly programmatically

Tags:

c#

nlog

I am using nlog v3 and I cannot figure out the way to do programatically what

  <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. Anybody knows how to do it in code?

like image 757
Dmitriy Avatar asked May 20 '15 04:05

Dmitriy


1 Answers

This should do it:

var assembly = Assembly.Load("NLog.MongoDB");
NLog.Config.ConfigurationItemFactory.Default.RegisterItemsFromAssembly(assembly);
like image 80
Matt Varblow Avatar answered Oct 16 '22 18:10

Matt Varblow