<?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"
      internalLogToConsole="false"
      internalLogToConsoleError="false"
      internalLogLevel="Error"
      internalLogFile="Logs/internal-nlog.txt">
  <!--日志级别 -->
  <!--internalLogLevel="Trace|Debug|Info|Warn|Error|Fatal" -->
  <!--define various log targets-->
  <targets>
    <default-wrapper xsi:type="BufferingWrapper" bufferSize="1"/>
    <target name="TRACE"
             xsi:type="Trace"
             layout="[${longdate}] ${logger}: ${newline}${message}${onexception:inner=${newline}${exception:format=ToString}}${newline}" />
    <!-- 常规的控制台输出 -->
    <target name="CONSOLE"
            xsi:type="Console"
            layout="[${longdate}] ${logger}: ${newline}${message}${onexception:inner=${newline}${exception:format=ToString}}${newline}" />
    <target name="LOG_CONSOLE"
            xsi:type="Console"
            layout="${message}" />
    <!-- 控制台的日志文件输出 -->
    <target name="CONSOLE_LOG_FILE"
            xsi:type="File"
            layout="${message}"
            encoding="utf-8"
            archiveNumbering="Date"
            archiveEvery="Day"
            archiveDateFormat="yyyy-MM-dd"
            archiveFileName="${basedir}/Logs/${shortdate}/Log_Console.log"
            fileName="${basedir}/Logs/${shortdate}/Log_Console.log" />
    <!-- 常规的日志文件输出 -->
    <target name="INFO_LOG_FILE"
            xsi:type="File"
            layout="[${longdate}] ${logger}: ${newline}${message}${onexception:inner=${newline}${exception:format=ToString}}${newline}"
            encoding="utf-8"
            archiveNumbering="Date"
            archiveEvery="Day"
            archiveDateFormat="yyyy-MM-dd"
            archiveFileName="${basedir}/Logs/${shortdate}/Log_Info.log"
            fileName="${basedir}/Logs/${shortdate}/Log_Info.log" />
    <!-- 错误的日志文件输出 -->
    <target name="ERROR_LOG_FILE"
            xsi:type="File"
            layout="[${longdate}] ${logger}: ${newline}${message}${onexception:inner=${newline}${exception:format=ToString}}${newline}"
            encoding="utf-8"
            archiveNumbering="Date"
            archiveEvery="Day"
            archiveDateFormat="yyyy-MM-dd"
            archiveFileName="${basedir}/Logs/${shortdate}/Log_Error.log"
            fileName="${basedir}/Logs/${shortdate}/Log_Error.log" />
    <!-- 调试的日志文件输出 -->
    <target name="DEBUG_LOG_FILE"
            xsi:type="File"
            layout="[${longdate}] ${logger}: ${newline}${message}${onexception:inner=${newline}${exception:format=ToString}}${newline}"
            encoding="utf-8"
            archiveNumbering="Date"
            archiveEvery="Day"
            archiveDateFormat="yyyy-MM-dd"
            archiveFileName="${basedir}/Logs/${shortdate}/Log_Debug.log"
            fileName="${basedir}/Logs/${shortdate}/Log_Debug.log" />
  </targets>

  <rules>
    <!-- 记录应用程序的 Debug 输出 -->
    <!--日志级别 -->
    <!--internalLogLevel="Trace|Debug|Info|Warn|Error|Fatal" -->
    <logger name="InfoMsg" minlevel="Info" writeTo="LOG_CONSOLE,INFO_LOG_FILE"  /> 
    <logger name="ErrorMsg" minlevel="Error" writeTo="TRACE,ERROR_LOG_FILE"  /> 
    <logger name="DebugMsg" minlevel="Debug" writeTo="LOG_CONSOLE"  />
  </rules>

</nlog>