|
|
|
|
<?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">
|
|
|
|
|
|
|
|
|
|
<!-- optional, add some variables
|
|
|
|
|
https://github.com/nlog/NLog/wiki/Configuration-file#variables
|
|
|
|
|
-->
|
|
|
|
|
<variable name="myvar" value="myvalue" />
|
|
|
|
|
|
|
|
|
|
<!--
|
|
|
|
|
See https://github.com/nlog/nlog/wiki/Configuration-file
|
|
|
|
|
for information on customizing logging rules and outputs.
|
|
|
|
|
-->
|
|
|
|
|
<targets async ="true">
|
|
|
|
|
|
|
|
|
|
<!--
|
|
|
|
|
add your targets here
|
|
|
|
|
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
|
|
|
|
|
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
|
|
|
|
|
-->
|
|
|
|
|
|
|
|
|
|
<!--
|
|
|
|
|
Write events to a file with the date in the filename.
|
|
|
|
|
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
|
|
|
|
|
layout="${longdate} ${uppercase:${level}} ${message}" />
|
|
|
|
|
-->
|
|
|
|
|
|
|
|
|
|
<!--Type输出类型:
|
|
|
|
|
Console 输出到控制台
|
|
|
|
|
Debugger 输出到VS输出窗口
|
|
|
|
|
File 输出到文件
|
|
|
|
|
Mail 输出为邮件发送
|
|
|
|
|
Network 输出到网络地址
|
|
|
|
|
Database 输出到数据库-->
|
|
|
|
|
<default-target-parameters xsi:type="File" createDirs="true" keepFileOpen="true" autoFlush="false" openFileFlushTimeout="10" openFileCacheTimeout="30" archiveAboveSize="52428800"
|
|
|
|
|
archiveNumbering="Sequence" concurrentWrites="true" encoding="UTF-8" />
|
|
|
|
|
<!-- 输出到文件,这个文件记录错误日志 -->
|
|
|
|
|
<target xsi:type="File" name="Error" fileName="Log/${shortdate}/Error.txt"
|
|
|
|
|
layout="
|
|
|
|
|
【时间】:${date} ${newline}
|
|
|
|
|
【级别】:${level:uppercase=true} ${newline}
|
|
|
|
|
【程序集信息】:${callsite:className=True:fileName=True:includeSourcePath=False:methodName=True} ${newline}
|
|
|
|
|
【堆栈信息】:${stacktrace}${newline}
|
|
|
|
|
【日志名称】:${logger}${newline}
|
|
|
|
|
【异常信息】:${exception:format=ToString}${newline}
|
|
|
|
|
【内容】:${message}${newline}" />
|
|
|
|
|
<!-- 输出到文件,这个文件记录警告日志 -->
|
|
|
|
|
<target xsi:type="File" name="Warn" fileName="Log/${shortdate}/Warn.txt"
|
|
|
|
|
layout="
|
|
|
|
|
【时间】:${date} ${newline}
|
|
|
|
|
【内容】:${message}${newline}" />
|
|
|
|
|
<!-- 输出到文件,这个文件记录消息日志 -->
|
|
|
|
|
<target xsi:type="File" name="Info" fileName="Log/${shortdate}/Info.txt"
|
|
|
|
|
layout="
|
|
|
|
|
【时间】:${date} ${newline}
|
|
|
|
|
【内容】:${message}${newline}" />
|
|
|
|
|
<!-- 输出到文件,这个文件记录操作日志 -->
|
|
|
|
|
<target xsi:type="File" name="Trace" fileName="Log/${shortdate}/Trace.txt"
|
|
|
|
|
layout="
|
|
|
|
|
【时间】:${date} ${newline}
|
|
|
|
|
【内容】:${message}${newline}" />
|
|
|
|
|
<!--输出到控制台,并添加必要的输出布局(layout)-->
|
|
|
|
|
<target xsi:type="Debugger" name="Debugger" layout="● ${longdate} ${level} ${logger} ${stacktrace}${message}" />
|
|
|
|
|
<!--说明:layout指定输出文件内容的样式 ${longdate}是日期(具体到毫秒),${level}是日志的等级;${message}是具体要输出的内容。-->
|
|
|
|
|
<!--输出日志到CSV文件-->
|
|
|
|
|
<!--<target name="csv" xsi:type="File" fileName="Log\${shortdate}\Csv.csv">
|
|
|
|
|
<layout xsi:type="CSVLayout">
|
|
|
|
|
<column name="time" layout="${longdate}" />
|
|
|
|
|
<column name="message" layout="${message}" />
|
|
|
|
|
<column name="logger" layout="${logger}" />
|
|
|
|
|
<column name="level" layout="${level}" />
|
|
|
|
|
</layout>
|
|
|
|
|
</target>-->
|
|
|
|
|
<target name="Debugger" xsi:type="Console" />
|
|
|
|
|
</targets>
|
|
|
|
|
<rules>
|
|
|
|
|
<!-- add your logging rules here -->
|
|
|
|
|
<!--
|
|
|
|
|
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
|
|
|
|
|
<logger name="*" minlevel="Debug" writeTo="f" />
|
|
|
|
|
-->
|
|
|
|
|
<!--NLog支持如下几种记录等级:
|
|
|
|
|
1.Trace - 最常见的记录信息,一般用于普通输出
|
|
|
|
|
2.Debug - 同样是记录信息,不过出现的频率要比Trace少一些,一般用来调试程序
|
|
|
|
|
3.Info - 信息类型的消息
|
|
|
|
|
4.Warn - 警告信息,一般用于比较重要的场合
|
|
|
|
|
5.Error - 错误信息
|
|
|
|
|
6.Fatal - 致命异常信息。一般来讲,发生致命异常之后程序将无法继续执行。-->
|
|
|
|
|
<logger name="*" level="Error" writeTo="Error" />
|
|
|
|
|
<logger name="*" level="Warn" writeTo="Warn" />
|
|
|
|
|
<logger name="*" level="Info" writeTo="Info" />
|
|
|
|
|
<logger name="*" level="Trace" writeTo="Trace" />
|
|
|
|
|
<!--将所有记录的信息输出至控制台-->
|
|
|
|
|
<logger name="*" writeTo="Debugger" />
|
|
|
|
|
<!--<logger name="*" minlevel="Debug" writeTo="Debugger" />
|
|
|
|
|
此处增加了一个minlevel="Warn",规则就变成了将所有记录等级大于等于Warn的等级信息输出至控制台-->
|
|
|
|
|
<!--<logger name="*" minlevel="Debug" writeTo="csv" />-->
|
|
|
|
|
</rules>
|
|
|
|
|
</nlog>
|
|
|
|
|
|