可用的nlog配置

 

<?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="false"
       >
  <targets async="true">
    <target name="file" xsi:type="File" fileName="${basedir}/Logs/${shortdate}.log" layout="[${longdate}] [${uppercase:${level}}] [${logger}] ${message} ${exception:format=tostring}"  concurrentWrites="false" keepFileOpen="false"/>
    <target name="console" xsi:type="ColoredConsole" layout="[${longdate}] [${uppercase:${level}}] [${logger:shortName=true}] ${message} ${exception:format=tostring}" />
    <target name="debug" xsi:type="File" fileName="${basedir}/Log/${date:format=yyyy-MM-dd HH}.debug.txt" />
    <target name="error" xsi:type="File" fileName="${basedir}/Log/${date:format=yyyy-MM-dd HH}.error.txt" />
    <target name="info" xsi:type="File" fileName="${basedir}/Log/${date:format=yyyy-MM-dd HH}.info.txt" />
    <target name="warn" xsi:type="File" fileName="${basedir}/Log/${date:format=yyyy-MM-dd HH}.warn.txt" />
  </targets>
  <rules>
    <logger name="*" writeTo="console,file" />
    <logger name="*" levels="Debug" writeTo="debug" />
    <logger name="*" levels="Error" writeTo="error" />
    <logger name="*" levels="Warn" writeTo="warn" />
  </rules>
</nlog>

 

上一篇:AspNetCore使用NLog做日志记录


下一篇:关于NLog在.NET CORE下如何进行日志的持久化及通过邮件发送日志