-
Notifications
You must be signed in to change notification settings - Fork 0
/
NLog.config
33 lines (28 loc) · 1.68 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
<?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">
<!--[變數] 文字樣板 -->
<variable name="Layout" value="${longdate} | ${level:uppercase=true} | ${logger} | ${message} ${newline}"/>
<variable name="LayoutFatal" value="${longdate} | ${level:uppercase=true} | ${logger} | ${message} | ${exception:format=tostring} ${newline}"/>
<!--[變數] 檔案位置 -->
<variable name="LogTxtDir" value="${basedir}/App_Data/Logs/${shortdate}/"/>
<variable name="LogTxtLocation" value="${LogTxtDir}/${logger}.log"/>
<variable name="LogTxtLocationFatal" value="${LogTxtDir}/FatalFile.log"/>
<!--[設定] 寫入目標-->
<targets>
<target name="File" xsi:type="File" fileName="${LogTxtLocation}" layout="${Layout}"
encoding="utf-8" maxArchiveFiles="30" archiveNumbering="Sequence"
archiveAboveSize="1048576" archiveFileName="${LogTxtDir}/${logger}.log{#######}" />
<target name="FileFatal" xsi:type="File" fileName="${LogTxtLocationFatal}" layout="${LayoutFatal}"
encoding="utf-8" maxArchiveFiles="30" archiveNumbering="Sequence"
archiveAboveSize="1048576" archiveFileName="${LogTxtDir}/FatalFile.log{#######}" />
<target name="EventLog" xsi:type="EventLog" source="NLogLogger" log="Application"
layout="${date}| ${level} | ${message}"/>
</targets>
<!--[設定] 紀錄規則-->
<rules>
<logger name="*" levels="Trace,Debug,Info,Warn" writeTo="File" />
<logger name="*" levels="Error,Fatal" writeTo="FileFatal" />
<logger name="*" levels="Fatal" writeTo="EventLog" />
</rules>
</nlog>