make NLog.config file load the file from (d:\dev) instead of "\bin\debug\"

The NLog config needs to reside in the folder where the app that is dynamically pulling a.dll is running from. If you are debugging, that is why it is works when you put it into bin\debug. If you are using Visual Studio, try setting your nlog.config to 'Copy Always' and it should go where you need it.


See Configuration file locations on the NLog wiki.

Basically the ways NLog locates the config is:

  • standard application configuration file (usually applicationname.exe.config)
  • applicationname.exe.nlog in application’s directory
  • NLog.config in application’s directory
  • NLog.dll.nlog in a directory where NLog.dll is located (only if NLog is not in the GAC)
  • file name pointed by the NLOG_GLOBAL_CONFIG_FILE environment variable (if defined, NLog 1.0 only - support removed in NLog 2.0)

There are no other way to do this.


Below is how i changed configuration of Nlog to point to Nlog.config file present in Executing Assembly's folder.

string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
NLog.LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration(assemblyFolder + "\\NLog.config");