NLog extensions add assembly programmatically

I am using nlog v3 and I cannot figure out how to do programmatically what

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

      

does. I found one answer on the old Nlog forums that might help, but that was for v1 and v2 and those classes are no longer there. Does anyone know how to do this in code?

+3


source to share


1 answer


This should do it:



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

      

+9


source







All Articles