<?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">
  <variable name="appType" value=""/>
  <variable name="appId" value=""/>
  <targets>
    <target name="all" xsi:type="File"
            fileName="${basedir}/../Logs/Log.txt"
            deleteOldFileOnStartup="false"
            layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}"/>
  </targets>

  <targets>
    <target name="console" xsi:type="ColoredConsole"
            layout="[${longdate}] ${message}">
      <highlight-row condition="logger == 'LogEvent' and starts-with(message,'|M|')" foregroundColor="Magenta"/>
      <highlight-row condition="logger == 'LogEvent' and starts-with(message,'|Y|')" foregroundColor="Yellow"/>
      <highlight-row condition="logger == 'LogEvent' and starts-with(message,'|B|')" foregroundColor="Blue"/>
      <highlight-row condition="logger == 'LogEvent' and starts-with(message,'|C|')" foregroundColor="Cyan"/>
      <highlight-row condition="logger == 'LogEvent' and starts-with(message,'|R|')" foregroundColor="Red"/>
      <highlight-row condition="logger == 'LogEvent'" foregroundColor="Green"/>

      <highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red"/>
      <highlight-row condition="level == LogLevel.Error" foregroundColor="Red"/>
      <highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow"/>
      <highlight-row condition="level == LogLevel.Info" foregroundColor="White"/>
      <highlight-row condition="level == LogLevel.Debug" foregroundColor="Gray"/>
      <highlight-row condition="level == LogLevel.Trace" foregroundColor="DarkGray"/>
    </target>
  </targets>

  <targets>
    <target name="trace" xsi:type="File"
            openFileCacheTimeout="3600"
            archiveAboveSize="10485760"
            fileName="${basedir}/../Logs/Trace/Trace-${var:appType}-${var:appIdFormat}-${date:universalTime=true:format=yyyyMMdd}.log"
            deleteOldFileOnStartup="false"
            layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${message} ${newline} ${stacktrace:format=Raw:topFrames=10:skipFrames=0}"/>
  </targets>

  <targets>
    <target name="debug" xsi:type="File"
            openFileCacheTimeout="3600"
            archiveAboveSize="10485760"
            fileName="${basedir}/../Logs/Debug/Debug-${var:appType}-${var:appIdFormat}-${date:universalTime=true:format=yyyyMMdd}.log"
            deleteOldFileOnStartup="false"
            layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}"/>
  </targets>

  <targets>
    <target name="info" xsi:type="File"
            openFileCacheTimeout="3600"
            archiveAboveSize="10485760"
            fileName="${basedir}/../Logs/Info/Info-${var:appType}-${var:appIdFormat}-${date:universalTime=true:format=yyyyMMdd}.log"
            deleteOldFileOnStartup="false"
            layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}"/>
  </targets>

  <targets>
    <target name="error" xsi:type="File"
            openFileCacheTimeout="3600"
            archiveAboveSize="10485760"
            fileName="${basedir}/../Logs/Error/Error-${var:appType}-${var:appIdFormat}-${date:universalTime=true:format=yyyyMMdd}.log"
            deleteOldFileOnStartup="false"
            layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${message} ${newline} ${stacktrace:format=Raw:topFrames=10:skipFrames=0}"/>
  </targets>

  <targets>
    <target name="warn" xsi:type="File"
            openFileCacheTimeout="3600"
            archiveAboveSize="10485760"
            fileName="${basedir}/../Logs/Warning/Warning-${var:appType}-${var:appIdFormat}-${date:universalTime=true:format=yyyyMMdd}.log"
            deleteOldFileOnStartup="false"
            layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${message} ${newline} ${stacktrace:format=Raw:topFrames=10:skipFrames=0}"/>
  </targets>

  <targets>
    <target name="fatal" xsi:type="File"
            openFileCacheTimeout="3600"
            archiveAboveSize="10485760"
            fileName="${basedir}/../Logs/Fatal/Fatal-${var:appType}-${var:appIdFormat}-${date:universalTime=true:format=yyyyMMdd}.log"
            deleteOldFileOnStartup="false"
            layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${message} ${newline} ${stacktrace:format=Raw:topFrames=10:skipFrames=0}"/>
  </targets>

  <targets>
    <target name="event" xsi:type="File"
            openFileCacheTimeout="3600"
            archiveAboveSize="10485760"
            fileName="${basedir}/../Logs/Event/Event-${var:appType}-${var:appIdFormat}-${date:universalTime=true:format=yyyyMM}.log"
            deleteOldFileOnStartup="false"
            layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=false:includeSourcePath=false:skipFrames=0} ${message}"/>
  </targets>

  <targets>
    <target name="analytics" xsi:type="File"
            openFileCacheTimeout="3600"
            archiveAboveSize="10485760"
            fileName="${basedir}/../Logs/Analytics/Analytics-${var:appIdFormat}-${date:universalTime=true:format=yyyyMMdd}.log"
            deleteOldFileOnStartup="false"
            layout="${message}"/>
    />
  </targets>

  <targets>
    <target name="acquisition" xsi:type="File"
            openFileCacheTimeout="3600"
            archiveAboveSize="10485760"
            fileName="${basedir}/../Logs/Acquisition/Acquisition-${var:appIdFormat}-${date:universalTime=true:format=yyyyMMdd}.log"
            deleteOldFileOnStartup="false"
            layout="${message}"/>
    />
  </targets>

  <rules>
    <logger name="Log*" minlevel="Trace" writeTo="console"/>
    <logger name="*" minlevel="Trace" maxlevel="Trace" writeTo="trace"/>
    <logger name="*" minlevel="Debug" maxlevel="Debug" writeTo="debug"/>
    <logger name="Log*" minlevel="Info" maxlevel="Info" writeTo="info"/>
    <logger name="*" minlevel="Warn" maxlevel="Warn" writeTo="warn"/>
    <logger name="*" minlevel="Error" maxlevel="Error" writeTo="error"/>
    <logger name="*" minlevel="Fatal" maxlevel="Fatal" writeTo="fatal"/>
    <logger name="LogEvent" minlevel="Info" maxlevel="Info" writeTo="event"/>
    <logger name="Acquisition" minlevel="Info" maxlevel="Info" writeTo="acquisition"/>
  </rules>
</nlog>