Nlog 配置文件说明

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
<?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"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="OFF" internalLogFile="c:\temp\nlog-internal.log">

<!-- 可选,添加一些变量
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="app_context" value="gis"/>
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
有关自定义日志规则和输出的信息。
-->
<targets>
<!--
在这里添加目标
See https://github.com/nlog/NLog/wiki/Targets 寻找可能的目标。.
See https://github.com/nlog/NLog/wiki/Layout-Renderers 对于可能的布局渲染器。
-->
<!--
将事件写入文件名中带有日期的文件。
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
<target xsi:type="File" name="f_app" fileName="${basedir}/GISAPP/logs/applog/applog-${shortdate}.log" archiveNumbering="Sequence" archiveEvery="Day" maxArchiveDays="30" archiveAboveSize="102400000"
layout="${longdate} ${message} ${exception}" />
<target xsi:type="File" name="f_net" fileName="${basedir}/GISAPP/logs/netlog/netlog-${shortdate}.log" archiveNumbering="Sequence" archiveEvery="Day" maxArchiveDays="30" archiveAboveSize="102400000"
layout="${longdate} ${message} ${exception}" />
</targets>
<rules>
<!--
将所有具有最小调试级别的事件(例如Debug, Info, Warn, Error和Fatal,但不包括Trace)写入"f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
<logger name="app_logger" minlevel="Trace" writeTo="f_app" />
<logger name="net_logger" minlevel="Trace" writeTo="f_net" />
</rules>
</nlog>