<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="LauncherDependencies" />
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Security.Cryptography.X509Certificates" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <nlog autoReload="true" throwExceptions="true" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <variable name="logDirectory" value="${basedir}/logs" />
    <targets>
      <target name="console" xsi:type="ColoredConsole" layout="${longdate} | ${level:uppercase=true} | ${logger} :: ${message}" />
      <target name="allLogsFile" xsi:type="AsyncWrapper" queueLimit="10000" timeToSleepBetweenBatches="100" overflowAction="Grow">
        <target xsi:type="File" fileName="${logDirectory}/RSServerLauncher.log" archiveFileName="${logDirectory}/archive/RSServerLauncher.{#}.log" archiveNumbering="DateAndSequence" archiveAboveSize="10485760" archiveDateFormat="yyyyMMdd" maxArchiveFiles="10" layout="${longdate}|${level:uppercase=true}|${logger} :: ${message}" />
      </target>
      <target name="connectionErrorsFile" xsi:type="AsyncWrapper" queueLimit="10000" timeToSleepBetweenBatches="100" overflowAction="Grow">
        <target xsi:type="File" fileName="${logDirectory}/connection-errors.log" archiveFileName="${logDirectory}/archive/connection-errors.{#}.log" archiveNumbering="DateAndSequence" archiveAboveSize="10485760" archiveDateFormat="yyyyMMdd" maxArchiveFiles="10" layout="${longdate}|${level:uppercase=true}|${logger} :: ${message}" />
      </target>
      <target name="seriousLogsFile" xsi:type="File" fileName="${logDirectory}/RSServerLauncher-errors.log" archiveFileName="${logDirectory}/archive/RSServerLauncher-errors.{#}.log" archiveNumbering="DateAndSequence" archiveAboveSize="10485760" archiveDateFormat="yyyyMMdd" maxArchiveFiles="50" layout="${longdate}|${level:uppercase=true}|${assembly-version}|${logger} :: ${message}" />
      <target name="nlogConf" xsi:type="File" fileName="${logDirectory}/RSServerLauncher-NLog.conf.log" archiveFileName="${logDirectory}/archive/RSServerLauncher-NLog.conf.log" archiveNumbering="DateAndSequence" archiveAboveSize="10485760" archiveDateFormat="yyyyMMdd" maxArchiveFiles="5" layout="${longdate}|${level:uppercase=true}|${assembly-version}|${logger} :: ${message}" />
      <target name="opcClientLogFile" xsi:type="AsyncWrapper" queueLimit="10000" timeToSleepBetweenBatches="100" overflowAction="Grow">
        <target xsi:type="File" fileName="${logDirectory}/opc-client.log" archiveFileName="${logDirectory}/archive/opc-client.{#}.log" archiveNumbering="DateAndSequence" archiveAboveSize="10485760" archiveDateFormat="yyyyMMdd" maxArchiveFiles="10" layout="${longdate}|${level:uppercase=true}|${logger} :: ${message}" />
      </target>
    </targets>
    <rules>
      <!-- filter all connection issues spam to seperate file -->
      <logger name="NLog.config" minlevel="Trace" writeTo="nlogConf" final="true" />
      <logger name="SendCheckInMessageToHubs" minlevel="Error" writeTo="connectionErrorsFile" final="true" />
      <logger name="SendGetServerTimeMessageToHubs" minlevel="Error" writeTo="connectionErrorsFile" final="true" />
      <logger name="SendNewChangesToHubs" minlevel="Warn" writeTo="connectionErrorsFile" final="true" />
      <logger name="OPC*" minlevel="Info" writeTo="opcClientLogFile" final="true" />
      <!-- actual logs: change minlevel="Info" to minlevel="Trace" for full debugging -->
      <logger name="*" minlevel="Info" writeTo="allLogsFile" />
      <logger name="*" minlevel="Error" writeTo="seriousLogsFile" />
      <logger name="*" minlevel="Warn" writeTo="console" />
    </rules>
  </nlog>
</configuration>