title: NLog does not create log folder anymore
body: <p>I have a weird behavior of my logging framework (NLog) for my WPF application. I tried to google the issue but I only found issues concerning NLog not creating the logfile.</p>
  <p>I have another problem. NLog throws an exception at the first attempt of logging something:</p>
  <blockquote>
  <p>System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\f.harreau\ScopIt\logs\2017-07-24.log'.</p>
  <p>at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)</p>
  </blockquote>
  <p>Before today, I never had this problem. I could delete the log folder, NLog recreated it at the application startup.</p>
  <p>If I create the folder manually, everything goes well. If the logfile does not exist, NLog creates the file. NLog just stopped creating the log folder.</p>
  <p>My coworker does not have the issue. He can delete the log folder, NLog recreate it at startup.</p>
  <p>So it looks like a computer issue. But if I run the installed version of my application, it does create the log folder if it does not exist. So may be a Visual Studio issue?</p>
  <p>Visual Studio is run as Administrator. I tried to &quot;reboot&quot; Visual Studio without success.</p>
  <p><strong>Do you have any idea of what could cause that?</strong></p>
  <p>Here is my NLog configuration:</p>
  <pre><code>var config = new LoggingConfiguration();
  
  config.Variables[&quot;logDirectory&quot;] = new SimpleLayout(@&quot;C:\Users\f.harreau\ScopIt\logs&quot;);
  
  // Creating Targets
  // -- All logs
  var allLogs = new FileTarget(&quot;allLogs&quot;);
  allLogs.Layout = &quot;${longdate} ${logger} ${uppercase:${level}} ${message}&quot;;
  allLogs.FileName = &quot;${var:logDirectory}/${shortdate}.log&quot;;
  // -- Expert system logs
  var expertSystemLogs = new FileTarget(&quot;expertSystemLogs&quot;);
  expertSystemLogs.Layout = &quot;${longdate} ${logger} ${uppercase:${level}} ${message}&quot;;
  expertSystemLogs.FileName = &quot;${var:logDirectory}/${shortdate}.expert_system.log&quot;;
  // -- Error logs
  var errorLogs = new FileTarget(&quot;errorLogs&quot;);
  errorLogs.Layout = &quot;${longdate} ${logger} ${uppercase:${level}} ${message} ${exception:format=tostring}&quot;;
  errorLogs.FileName = &quot;${var:logDirectory}/${shortdate}.errors.log&quot;;
  
  // Adding the targets to the config
  config.AddTarget(allLogs);
  config.AddTarget(expertSystemLogs);
  config.AddTarget(errorLogs);
  
  // Defining rules
  config.LoggingRules.Add(new LoggingRule(&quot;*&quot;, LogLevel.Trace, allLogs));
  config.LoggingRules.Add(new LoggingRule(&quot;*&quot;, LogLevel.Error, errorLogs));
  config.LoggingRules.Add(new LoggingRule(&quot;MyCompany.ExpertSystem.*&quot;, LogLevel.Info, expertSystemLogs));
  
  // Activating the configuration
  LogManager.Configuration = config;
  </code></pre>