<?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"
      internalLogLevel="info"
      internalLogFile="c:\Temp\GrapefruitVuCore\internal-nlog.txt">

  <!-- enable asp.net core and mongodb layout renderers -->
  <extensions>
    <add assembly="NLog.Web.AspNetCore"/>
    <add assembly="NLog.Mongo"/>
  </extensions>

  <!--internal-nlog:NLog启动及加载config信息-->
  <!--nlog-all:所有日志记录信息-->
  <!--nlog-own:自定义日志记录信息-->

  <!-- the targets to write to -->
  <targets>
    <!-- write logs to file  -->
    <target xsi:type="File" name="allfile" fileName="${basedir}/Logs/${shortdate}/${level}.log"
            layout="日志记录时间：${longdate}${newline}日志级别：${uppercase:${level}}${newline}日志来源：${logger}${newline}日志信息：${message}${newline}错误信息：${exception:format=tostring}${newline}==============================================================${newline}" />

    <!-- another file log, only own logs. Uses some ASP.NET core renderers -->
    <target xsi:type="File" name="ownFile-web" fileName="${basedir}/Logs/${shortdate}/${level}.log"
            layout="日志记录时间：${longdate}${newline}日志级别：${uppercase:${level}}${newline}日志来源：${logger}${newline}日志信息：${message}${newline}错误信息：${exception:format=tostring}${newline}url: ${aspnet-request-url}${newline}action: ${aspnet-mvc-action}${newline}==============================================================${newline}" />

    <!-- write log to mongodb-->
    <!--<target xsi:type="Mongo"
            name="mongo" databaseName="nlog"
            collectionName="Logs"
            connectionString="mongodb://172.31.216.37:27017/nlog"
            cappedCollectionSize="26214400">
      <property name="LongDate" layout="${longdate}" bsonType="DateTime" />
      <property name="Level" layout="${level}" />
      <property name="Logger" layout="${logger}"/>
      <property name="Message" layout="${message}" />
      <property name="Exception" layout="${exception:format=tostring}" />
      <property name="Url" layout="${aspnet-request-url}" />
      <property name="Action" layout="${aspnet-mvc-action}" />
      <property name="UserName" layout="${windows-identity}" />
    </target>-->

  </targets>

  <!-- rules to map from logger name to target -->
  <rules>
    <!--All logs, including from Microsoft-->
    <logger name="*" minlevel="Trace" writeTo="allfile" />

    <!--Skip non-critical Microsoft logs and so log only own logs-->
    <logger name="Microsoft.*" maxLevel="Info" final="true" />
    <!-- BlackHole without writeTo -->
    <logger name="*" minlevel="Trace" writeTo="ownFile-web" />

    <!--Add logs to mongodb-->
    <!--<logger name="*" minlevel="Trace" writeTo="mongo"/>-->
  </rules>
</nlog>