可用的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>

 

posted @ 2021-08-19 20:19  wolbo  阅读(26)  评论(0编辑  收藏  举报