I have .Net Framework 4.7.2 Console app running on Windows 10 (64bit), which is called thru Task Scheduler periodically.
When the task is run the log file gets created inside C:\Windows\SysWOW64
, if I switch to ${basedir}
instead of ${currentdir}
, it creates file where the exe is located.
I am puzzled is this correct behaviour, that ${currentdir}
creates files in C:\Windows\SysWOW64
? Before I log a issue with NLog, I thought I should check on SO first.
Their documentation on ${basedir}
or ${currentdir}
doesn't state the difference between two or explains which option to use when.
NLog version: 4.6.3
Below is my nlog.config file:
<?xml version="1.0" encoding="utf-8" ?>
<!-- XSD manual extracted from package NLog.Schema: https://www.nuget.org/packages/NLog.Schema-->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xsi:schemaLocation="NLog NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogFile="nlog-internal.log"
internalLogLevel="Info">
<variable name="format" value="${threadid}|${longdate}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<variable name="path" value="${currentdir}" /> <!-- Using ${basedir} works -->
<!-- the targets to write to -->
<targets>
<!-- write logs to file -->
<target xsi:type="Console" name="console" layout="${var:format}" />
<target xsi:type="File" name="mslog" fileName="${var:path}\mslog-${shortdate}.log" layout="${var:format}" />
<target xsi:type="File" name="datadaptorlogs" fileName="${var:path}\datadaptor-${shortdate}.log" layout="${var:format}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<logger name="*" minlevel="Trace" writeTo="datadaptorlogs,console" />
<logger name="Microsoft.*" minlevel="Error" writeTo="mslog" />
</rules>
</nlog>