I'm trying to test NLog under LINQPad.
I successfully linked it and my code compiles well. However, NLog doesn't write log files because it is not configured.
I tried to make various config files like:
int zero = 0;
int result = 5 / zero;
catch (DivideByZeroException ex)
Logger logger = LogManager.GetCurrentClassLogger();
<?xml version="1.0" encoding="utf-8" ?>
<target name="logfile" xsi:type="File" fileName="logfile.log" />
<logger name="*" minlevel="Info" writeTo="logfile" />
Thanks to @pasty and @nemesv comments, the problem is fixed.
The config file must be named NLog.config and must be placed in the LINQPad.exe folder.
The log file (
logfile.log in my case) appears in the same folder.
LINQPad needs write access to the folder in order to write the log file.
LINQPad must be restarted after setting the config file.
If you start LINQPad, load or write the code and run it, the log file appears in the LINQPad.exe folder.
If you run the code by clicking on saved code file like
NLog Test.linq in my case, the log file appears in the folder of the code file. (
C:\Users\Miroslav\Documents\LINQPad Queries in my case)