<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      throwExceptions="false"
      internalLogLevel="Off"
      internalLogFile="NLog.log">

  <variable name="appName" value="DirectoryMonitor" />
  <variable name="defaultLayout" value="${longdate} - ${level:uppercase=true}: ${message}" />
  <variable name="defaultLayoutException" value="${defaultLayout}${newline}EXCEPTION: ${exception:format=ToString}" />

  <targets async="true">

    <!-- File Logger -->
    <target name="default"
            xsi:type="FilteringWrapper"
            condition="length('${exception}')==0">
      <target xsi:type="File"
              layout="${defaultLayout}"
              fileName=".\Data\Logs\Activity.log"
              encoding="utf-8"
              keepFileOpen="false"
              archiveFileName=".\Data\Logs\Activity_${shortdate}.{##}.log"
              archiveNumbering="Rolling"
              archiveEvery="Day"
              maxArchiveFiles="14"
              />
    </target>

    <target name="defaultException"
            xsi:type="FilteringWrapper"
            condition="length('${exception}')>0">
      <target xsi:type="File"
              layout="${defaultLayoutException}"
              fileName=".\Data\Logs\Activity.log"
              encoding="utf-8"
              keepFileOpen="false"
              archiveFileName=".\Data\Logs\Activity_${shortdate}.{##}.log"
              archiveNumbering="Rolling"
              archiveEvery="Day"
              maxArchiveFiles="14"
              />
    </target>

    <!-- Console Logger -->
    <target name="console"
            xsi:type="FilteringWrapper"
            condition="length('${exception}')==0">
      <target xsi:type="ColoredConsole"
              layout="${defaultLayout}"
              useDefaultRowHighlightingRules="true"
              />
    </target>

    <target xsi:type="FilteringWrapper"
            name="consoleException"
            condition="length('${exception}')>0">
      <target xsi:type="ColoredConsole"
              layout="${defaultLayoutException}"
              useDefaultRowHighlightingRules="true"
              />
    </target>

    <!-- Event Log Logger -->
    <target xsi:type="EventLog"
        name="eventlog"
        source="${appName}"
        layout="${defaultLayoutException}"
        />

  </targets>
  <rules>
    <logger name="DevEnterprise" writeTo="default,defaultException" minlevel="Info" />
    <logger name="DevEnterprise" writeTo="eventlog" minlevel="Error" />
    <!--<logger name="DevEnterprise" writeTo="console,consoleException" minlevel="Info" />-->
  </rules>
</nlog>