-
Notifications
You must be signed in to change notification settings - Fork 5
/
nlog.config
58 lines (43 loc) · 2.38 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?xml version="1.0" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Warn"
internalLogFile="App_Data\Logs\nlogs.log"
>
<!-- 定义日志输出的根目录为web目录的上级目录 -->
<variable name="logdir" value="${basedir}\..\..\..\..\logs"/>
<!--定义日志的目标/输出-->
<targets async="true">
<default-target-parameters
type="File"
archiveAboveSize="50485760"
maxArchiveFiles="50"
archiveNumbering="Rolling"
keepFileOpen="false"
layout="${date:format=HH\:mm\:ss\:ffff}:[${level}] ${callsite} ${onexception:${exception:format=tostring} ${newline}${stacktrace}${newline}"/>
<!--屏幕彩色打印消息-->
<target name="console" xsi:type="ColoredConsole"
layout="${date:format=HH\:mm\:ss\:ffff}:[${level}] ${message}"/>
<!--保存至按类名命名的日志文件中 | ${level:uppercase=false:padding=-5} | -->
<target name="warnLog" xsi:type="File" maxArchiveFiles="30"
fileName="${logdir}\${date:format=yyyy_MM}\${date:format=yyyy_MM_dd}_${logger}_${level}.log"
layout="${date:format=HH\:mm\:ss\:ffff}: ${message} ${onexception:${exception:format=tostring} ${newline}${stacktrace}${newline}" />
<target name="infoLog" xsi:type="File" maxArchiveFiles="30"
fileName="${logdir}\${date:format=yyyy_MM}\${date:format=yyyy_MM_dd}_info_${level}.log"
layout="${date:format=HH\:mm\:ss\:ffff}:[${logger}] ${message} ${onexception:${exception:format=tostring} ${newline}${stacktrace}${newline}" />
<target name="debugLog" xsi:type="File" maxArchiveFiles="30"
fileName="${logdir}\${date:format=yyyy_MM}\${date:format=yyyy_MM_dd}_debug_${level}.log"
layout="${date:format=HH\:mm\:ss\:ffff}:[${level}][${logger}] ${message} ${onexception:${exception:format=tostring} ${newline}${stacktrace}${newline}" />
</targets>
<!--
NOTE:Trace至Debug至一个单独的文件中
Info一个单独的文件
Warn开始,全部是独立的文件
-->
<rules>
<logger name="*" levels="Trace,Debug" writeTo="console,debugLog" />
<logger name="*" levels="Info" writeTo="console,infoLog" />
<logger name="*" minlevel="Warn" writeTo="console,warnLog" />
</rules>
</nlog>