Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After digging around in the NLog source code I finally figured out what was going on here.</p> <p>The real problem was that I was putting the NLog.config file in the wrong place and so NLog was not finding it. I was putting it in the Add-In directory with the .AddIn file and the binaries. Rather than throwing some kind of exception NLog was just silently disabling logging. This is perfectly reasonable behavior in hindsight since it's legitimate for logging to be just disabled if the config file is not present. Anyway, no logs were getting written and my first thought was that it might be a permissions issue. I then just tried to create a file (test.log) and write to it in my Add-In code and then saw the exception above which just reinforced my (incorrect) suspicion that there's some security model that prevents Add-Ins from writing to the file system.</p> <p>So, we need to be mindful of directories:</p> <ul> <li><p>The Add-in Directory: This is where the .AddIn file and related binaries will live. This is where Visual Studio will look for Add-ins and load them from.</p></li> <li><p>The default directory for Visual Studio: Remember that it's devenv.exe that owns the process, not the Add-in. So the default directory will be where devenv.exe lives not where the Add-in lives. Also note that this directory is write protected for non-Admin users. This is where NLog will look for the NLog.config file!</p></li> <li><p>The path to the logfile target in the NLog.config file: This needs to be a writeable location. Just specifying a file (e.g. test.log) in the target will represent a file in the default working dir for Visual Studio which, as we noted above, is not a writeable location.</p></li> </ul> <p>So, in order to make things work I had to:</p> <ul> <li>Put the NLog.config file in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE. I needed to do this as Admin.</li> <li>Specify a full (writeable) path for the logfile in NLog.config</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload