-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnlog.config
More file actions
120 lines (110 loc) · 5.18 KB
/
nlog.config
File metadata and controls
120 lines (110 loc) · 5.18 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?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"
autoReload="true"
internalLogLevel="Info"
internalLogFile="internal-nlog-AspNetCore.txt">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<!-- 變數設置 -->
<variable name="logDirectory" value="D:/AGVSystemLog/VMSLog/" />
<variable name="dateFolder" value="${logDirectory}/${date:format=yyyy-MM-dd}"/>
<variable name="hourFileName" value="${date:format=yyyy-MM-dd HH}.log"/>
<variable name="textLogLineLayout" value="${longdate} |${level}| [${logger:shortName=true}] ${message} ${exception:format=ToString,Data:maxInnerExceptionLevel=10}" />
<variable name="taskDispatchtextLogLineLayout" value="${longdate} |${level}| ${message} ${exception:format=ToString,Data:maxInnerExceptionLevel=10}" />
<variable name="consoleLogLineLayout" value="[${longdate}] | ${logger:shortName=true}| ${level}| ${message} ${exception:format=ToString,Data:maxInnerExceptionLevel=10}" />
<!-- AsyncWrapper 共用設置 -->
<variable name="asyncQueueLimit" value="10000" />
<variable name="asyncOverflowAction" value="Block" />
<variable name="asyncTimeToSleep" value="50" />
<!-- the targets to write to -->
<targets>
<!-- File Target for all log messages with basic details -->
<!--<target xsi:type="File" name="allfile" fileName="c:\temp\nlog-AspNetCore-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${level:uppercase=true}|${logger}|${message} ${exception:format=tostring}" />-->
<!-- 文件目标,根據日期和類別名稱分資料夾 -->
<target name="async-each-logger" xsi:type="AsyncWrapper"
queueLimit="${asyncQueueLimit}"
overflowAction="${asyncOverflowAction}"
timeToSleepBetweenBatches="${asyncTimeToSleep}">
<target xsi:type="File"
keepFileOpen="false"
concurrentWrites="true"
name="each-logger"
fileName="${dateFolder}/${logger:shortName=true}/${hourFileName}"
layout="${textLogLineLayout}" />
</target>
<!-- TaskDispatch -->
<target name="async-taskDispatch" xsi:type="AsyncWrapper"
queueLimit="${asyncQueueLimit}"
overflowAction="${asyncOverflowAction}"
timeToSleepBetweenBatches="${asyncTimeToSleep}">
<target xsi:type="File"
keepFileOpen="false"
concurrentWrites="true"
name="taskDispatch"
fileName="${dateFolder}/${logger}.log"
layout="${taskDispatchtextLogLineLayout}" />
</target>
<target name="async-vehicle-state" xsi:type="AsyncWrapper"
queueLimit="${asyncQueueLimit}"
overflowAction="${asyncOverflowAction}"
timeToSleepBetweenBatches="${asyncTimeToSleep}">
<target xsi:type="File"
keepFileOpen="false"
concurrentWrites="true"
name="vehicle-state"
fileName="${dateFolder}/${logger}/${hourFileName}"
layout="${textLogLineLayout}" />
</target>
<!--Console Target - 改為同步 -->
<target xsi:type="Console"
name="console-log"
layout="${consoleLogLineLayout}" />
<!-- EF Core Target -->
<target name="async-efcore" xsi:type="AsyncWrapper"
queueLimit="${asyncQueueLimit}"
overflowAction="${asyncOverflowAction}"
timeToSleepBetweenBatches="${asyncTimeToSleep}">
<target xsi:type="File"
keepFileOpen="false"
concurrentWrites="true"
name="efcore"
fileName="${dateFolder}/EFCore/${hourFileName}"
layout="${textLogLineLayout}" />
</target>
<target name="async-all-in-one" xsi:type="AsyncWrapper"
queueLimit="${asyncQueueLimit}"
overflowAction="${asyncOverflowAction}"
timeToSleepBetweenBatches="${asyncTimeToSleep}">
<target xsi:type="File"
keepFileOpen="false"
concurrentWrites="false"
openFileCacheTimeout="30"
name="all-in-one"
fileName="${dateFolder}/${hourFileName}"
layout="${textLogLineLayout}"
bufferSize="32768"/>
</target>
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!-- 忽略規則 | maxlevel="Warning" => 表示僅記錄Warning以上 -->
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" final="true" />
<logger name="System.Net.Http.*" minlevel="Info" final="true" />
<logger name="Microsoft.EntityFrameworkCore.*" minlevel="Warning" writeTo="async-efcore" final="true"/>
<logger name="Microsoft.*" maxlevel="Warning" final="true" />
<logger name="VehicleState/*" minlevel="Trace" writeTo="async-vehicle-state" final="true"/>
<logger name="VmsApiLoggingMiddleware*" minlevel="Trace" writeTo="async-each-logger" final="true" />
<logger name="PCPerformanceLog*" minlevel="Trace" writeTo="async-each-logger" final="true" />
<logger name="*" minlevel="Trace" writeTo="async-all-in-one" />
<logger name="TaskDispatch*" minlevel="Trace" writeTo="async-taskDispatch" final="true" />
<logger name="*" minlevel="Trace" writeTo="async-each-logger" />
<logger name="AGVSystemCommonNet6.AGVDispatch.*" maxlevel="Warning" final="true" />
<logger name="TaskExecuteHelper/*" maxlevel="Warning" final="true"/>
<logger name="NotifierLog" maxlevel="Warning" final="true"/>
<logger name="*" minlevel="Info" writeTo="console-log" />
</rules>
</nlog>