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

  <!-- 
  See https://github.com/nlog/nlog/wiki/Configuration-file 
  for information on customizing logging rules and outputs.
   -->

  <variable name="logDirectory" value="${basedir}/log"/>
  <variable name="logDirectoryArchive" value="${logDirectory}/archive"/>

  <targets>
    <!-- Таргет для логирования ошибок -->
    <target name="fileExceptionModule" type="AsyncWrapper" queueLimit="5000" overflowAction="Block">
      <target type="File" fileName="${logDirectory}/${date:format=yyyyMMdd}_exception.log"
              layout="${longdate}|ThreadId_${threadid}|${level:uppercase=true}|${message}|${exception:format=toString,Data:maxInnerExceptionLevel=5}|${stacktrace:topFrames=20:skipFrames=5}"
              archiveFileName="${logDirectoryArchive}/{#}_exception.log"
              archiveEvery="Day"
              archiveNumbering="DateAndSequence"
              archiveDateFormat="yyyyMMdd"
              maxArchiveFiles="365"
              archiveOldFileOnStartup="true"
              encoding ="UTF-8"/>
    </target>
    <!-- Таргет для логирования информационных сообщений -->
    <target name="fileModule" type="AsyncWrapper" queueLimit="5000" overflowAction="Block">
      <target type="File" fileName="${logDirectory}/${date:format=yyyyMMdd}.log"
              layout="${longdate}|${level:uppercase=true}|${logger}|${message}"
              archiveFileName="${logDirectoryArchive}/{#}.log"
              archiveEvery="Day"
              archiveNumbering="DateAndSequence"
              archiveDateFormat="yyyyMMdd"
              maxArchiveFiles="365"
              archiveOldFileOnStartup="true"
              encoding ="UTF-8"/>
    </target>
  </targets>

  <rules>
    <logger name="Default" minlevel="Error" maxlevel ="Error" writeTo="fileExceptionModule" />
    <logger name="Default" minlevel="Info"  writeTo="fileModule" />
  </rules>
</nlog>
