<?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"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
      autoReload="true"
      throwExceptions="true" 
      internalLogLevel="Off" 
      internalLogFile="${specialfolder:folder=ApplicationData}/QI4A/LogFiles/internal.log">

  <extensions>
    <add assembly="NLog.Targets.Http" />
  </extensions>

  <!-- optional, add some variables
  https://github.com/nlog/NLog/wiki/Configuration-file#variables
  -->
  <variable name="ApplicationName" value="QDA"/>

  <!--
  See https://github.com/nlog/nlog/wiki/Configuration-file
  for information on customizing logging rules and outputs.
   -->
  <targets async="true">

    
    <!--
    add your targets here
    See https://github.com/nlog/NLog/wiki/Targets for possible targets.
    See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
    -->

    <!--
    Write events to a file with the date in the filename.
    <target xsi:type="File" name="f" fileName="${specialfolder:folder=ApplicationData}/QI4A/logs/${shortdate}.log"
            layout="${longdate} ${uppercase:${level}} ${message}" />
    -->
    <target name="ErrorLog" xsi:type="File" encoding="utf-8" writeBom="false"
            fileName="${specialfolder:folder=ApplicationData}/QI4A/LogFiles/${ApplicationName}-${date:format=yyyyMMdd}-${machinename}-Error.log"
            layout="${longdate}|${machinename}|${logger}|${uppercase:${level}}|${message} | ${exception:format=ToString,StackTrace}" />

    <target name="FullLog" xsi:type="File" encoding="utf-8" writeBom="false"
            fileName="${specialfolder:folder=ApplicationData}/QI4A/LogFiles/${ApplicationName}-${date:format=yyyyMMdd}-${machinename}.log"
            layout="${longdate}|${machinename}|${logger}|${uppercase:${level}}|${message} | ${exception:format=ToString,StackTrace}" />
    
    <target name="logconsole" encoding="utf-8" xsi:type="Console" />

    <target name="Web"
            type="HTTP"
            URL="http://www.selab.cloud.com:7010/api/v1/logger"
            Method="POST"
            Authorization=""
            BatchSize="1"
            MaxQueueSize="2147483647"
            IgnoreSslErrors="true"
            FlushBeforeShutdown="true"
            ContentType="application/json"
            Accept="application/json"
            DefaultConnectionLimit="2"
            Expect100Continue="false"
            UseNagleAlgorithm="true"
            ConnectTimeout="5000"
            InMemoryCompression="true"
            ProxyUrl=""
            ProxyUser=""
            ProxyPassword="">
      <layout type="JsonLayout">
        <attribute name="longdate" layout="${longdate}" />
        <attribute name="machinename" layout="${machinename}" />
        <attribute name="logger" layout="${logger}" />
        <attribute name="level" layout="${uppercase:${level}}" />
        <attribute name="message" layout="${message}" />
        <attribute name="exception" layout="${exception:format=ToString,StackTrace}" />
      </layout>
    </target>
  </targets>

  <rules>
    <!-- add your logging rules here -->

    <!--
    Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace)  to "f"
    <logger name="*" minlevel="Debug" writeTo="f" />
      Trace - very detailed logs, which may include high-volume information such as protocol payloads. This log level is typically only enabled during development
      Debug - debugging information, less detailed than trace, typically not enabled in production environment.
      Info - information messages, which are normally enabled in production environment
      Warn - warning messages, typically for non-critical issues, which can be recovered or which are temporary failures
      Error - error messages - most of the time these are Exceptions
      Fatal - very serious errors!
    -->
    <logger name="*" minlevel="Error" writeTo="ErrorLog" />
    
    <logger name="*" minlevel="Trace" writeTo="FullLog" />
    
    <logger name="*" minlevel="Trace" writeTo="logconsole" />

    <logger name="*" minlevel="Trace" writeTo="Web" />

  </rules>
</nlog>
