-
Notifications
You must be signed in to change notification settings - Fork 102
/
nlog.config
34 lines (34 loc) · 2.48 KB
/
nlog.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?xml version="1.0" encoding="utf-8"?>
<!-- XSD manual extracted from package NLog.Schema: https://www.nuget.org/packages/NLog.Schema-->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" throwExceptions="false" protectedLogLevel="Off" protectedLogFile="NlogRecords.log">
<!--Nlog内部日志记录为Off关闭。除非纠错,不可以设为Trace否则速度很慢,起码Debug以上-->
<targets async="true">
<target name="fileTarget" xsi:type="File" fileName="${basedir}/log/${shortdate}.log"
layout="[${longdate}] | ${level:uppercase=false} | ${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}"
/>
<!--ColoredConsole彩色控制台 xsi:type="Console"是指定输出到普通控制台-->
<target name="consoleTarget" xsi:type="ColoredConsole" useDefaultRowHighlightingRules="true"
layout="[${time}] ${message} ${exception}" bufferSize="2048">
<highlight-row condition="level == LogLevel.Trace" foregroundColor="DarkGray"/>
<highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkMagenta"/>
<highlight-row condition="level == LogLevel.Info" foregroundColor="Green"/>
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow"/>
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red"/>
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="Magenta" backgroundColor="White"/>
</target>
</targets>
<rules>
<!--跳过所有级别的Microsoft组件的日志记录-->
<logger name="Microsoft.*" maxlevel="Info" final="true"/>
<!-- BlackHole without writeTo -->
<!--只通过数据库记录日志,这里的*,如果给了name名字,代码里用日志记录的时候,取logger需要把name当做参数-->
<logger name="*" minlevel="Trace" writeTo="fileTarget,consoleTarget"/>
<!--<logger name="*" minlevel="Debug" writeTo="fileTarget,consoleTarget" />
<logger name="*" minlevel="Trace" writeTo="fileTarget,consoleTarget" />
<logger name="*" minlevel="Warn" writeTo="fileTarget,consoleTarget" />
<logger name="*" minlevel="Error" writeTo="fileTarget,consoleTarget" />-->
<!--记录致命错误到控制台-->
<logger name="*" minlevel="Fatal" writeTo="fileTarget,consoleTarget"/>
</rules>
</nlog>