You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
3.1 KiB
XML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?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"
throwConfigExceptions="true"
autoReload="true">
<!--加载ASP.NET Core插件-->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<!--输出目的地-->
<targets>
<!--输出到文件,记录level为info的日志-->
<!-- <target xsi:type="File"
name="info-file"
fileName="c:\logfiles\webapi\info-${shortdate}.log"
layout="${longdate}|${uppercase:${level}}|${event-properties:item=EventId.Id}${newline}位置:${callsite:className=True:methodName=True:fileName=True:includeSourcePath=True:skipFrames=1}${newline}${message}${newline}${exception}${newline}"
/> -->
<!--输出到文件,记录level为error的日志-->
<!-- <target xsi:type="File"
name="error-file"
fileName="c:\logfiles\webapi\error-${shortdate}.log"
layout="${longdate}|${uppercase:${level}}|${event-properties:item=EventId.Id}${newline}位置:${callsite:className=True:methodName=True:fileName=True:includeSourcePath=True:skipFrames=1}${newline}${message}${newline}${exception}${newline}"
/> -->
<!-- 设置每个txt文件大小 -->
<!--archiveFileName表示滚动日志存放路径超过单个文件大小会生成如error-2019-03-30.1.log的文件-->
<!--archiveAboveSize表示每个日志文件大小的最大值单位字节-->
<!--maxArchiveFiles表示滚动日志文件上限数-->
<target xsi:type="File"
name="info-file"
layout="${longdate}|${uppercase:${level}}|${event-properties:item=EventId.Id}${newline}位置:${callsite:className=True:methodName=True:fileName=True:includeSourcePath=True:skipFrames=1}${newline}${message}${newline}${exception}${newline}"
fileName="${basedir}\DataUser\Log\info\info-${shortdate}.log"
archiveFileName="${basedir}\DataUser\info-${shortdate}.log"
archiveAboveSize="10485760"
archiveNumbering="Rolling"
concurrentWrites="true"
maxArchiveFiles="100000"
keepFileOpen="false"
/>
<target xsi:type="File"
name="error-file"
layout="${longdate}|${uppercase:${level}}|${event-properties:item=EventId.Id}${newline}位置:${callsite:className=True:methodName=True:fileName=True:includeSourcePath=True:skipFrames=1}${newline}${message}${newline}${exception}${newline}"
fileName="${basedir}\DataUser\Log\error\error-${shortdate}.log"
archiveFileName="${basedir}\DataUser\error-${shortdate}.log"
archiveAboveSize="10485760"
archiveNumbering="Rolling"
concurrentWrites="true"
maxArchiveFiles="100000"
keepFileOpen="false"
/>
<!--write to the void aka just remove-->
<target xsi:type="Null" name="blackhole" />
</targets>
<!-- 写入目的地的规则 -->
<rules>
<!--记录level为info的日志-->
<!-- 跳过以Microsoft.*开头的日志 -->
<logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />
<logger name="*" level="Info" writeTo="info-file" />
<!--记录level为error的日志-->
<logger name="*" level="Error" writeTo="error-file" />
</rules>
</nlog>