I have sort of plugin architecture in my solution. There is a well-known folder where to place plugins in it. The plugins implement an interface which is shared in the host project.
Initially i load the plugin via Assembly.LoadFrom(fi.FullName).GetTypes()
and instanciate the needed type by (IPlugin)Activator.CreateInstance(type);
.
So the host (main application) can execute appropriate code implemented by the plugin assembly. This works fine so far.
But recently i tried to implement application logging via NLog and configured NLog in the host project which worked great.
The problem is i would like to use (the already configured) logger in the plugin assembly.
If i just reference NLog and use it by LogManager.GetCurrentClassLogger();
there seems to be no configuration set. It does not log to the files i configured in the host project out of the plugin assembly.
I thought of trying to inject an NLogger instance (created in the host project) to a property of the plugin type.
Is this possible or is there a preferred way to accomplish things like that? Thanks