<nlog autoReload="true" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<variable name="appName" value="server.demo"/>
<targets>
<!-- 本地文件日志target -->
<target xsi:type="File"
name="file"
archiveAboveSize="20000000"
fileName="${basedir}/Log/${shortdate}/${lowercase:${level}}.log"
layout="${longdate} | ${level:uppercase=false} | ${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}"
keepFileOpen="false"
archiveNumbering="Rolling"
encoding="UTF-8"
enableFileDelete="true"
maxArchiveFiles="5"
/>
<!-- Tcp日志target -->
<target
name="network"
xsi:type="Network"
address="udp://127.0.0.1:5044"
layout="#${longdate}#${uppercase:${level}}#${appName}#${message}#${exception:format=ToString}#${stacktrace}#"
>
</target>
<!--空白-->
<target xsi:type="Null" name="blackhole" />
</targets>
<rules>
<!--自定义日志,排除Microsoft日志-->
<logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />
<logger name="*" minlevel="Debug" writeTo="file" />
<logger name="*" minlevel="Debug" writeTo="network" />
</rules>
</nlog>