You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
3.2 KiB
Plaintext

11 months ago
<?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"
throwConfigExceptions="false"
internalLogLevel="Off" >
<!--autoReload修改后自动加载可能会有延迟-->
<!--throwConfigExceptionsNLog日志系统抛出异常-->
<!--internalLogLevel内部日志的级别-->
<!--internalLogFile内部日志保存路径日志的内容大概就是NLog的版本信息配置文件的地址等等-->
<targets>
<target name="info" xsi:type="File" maxArchiveFiles="30" archiveAboveSize="10240000"
fileName="${basedir}/Logs/${shortdate}/info.txt"
layout="${longdate} | ${level} | ${message}" />
<!-- 请求响应日志记录 -->
<target name="requResp" xsi:type="File" maxArchiveFiles="30" archiveAboveSize="10240000"
fileName="${basedir}/Logs/${shortdate}/requResp.txt"
layout="${longdate} | ${level} | ${message}" />
<!--只保存error级别的日志可以快速知道是否有异常产生-->
<target name="error" xsi:type="File" maxArchiveFiles="30" archiveAboveSize="10240000"
fileName="${basedir}/Logs/${shortdate}/error.txt"
layout="${longdate} | ${level} | ${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}" />
<!--保存大数据量的日志,采用异步的方式-->
<target name="big" xsi:type="AsyncWrapper">
<target xsi:type="File" maxArchiveFiles="30" archiveAboveSize="10240000"
fileName="${basedir}/Logs/${shortdate}/bigData.txt"
layout="${longdate} | ${level} | ${message}" />
</target>
<!-- write log message to database -->
<target name="db" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
<target type="Database" dbProvider="mssql"
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=EFinance;Persist Security Info=True;User ID=sa;Password=123456;">
<commandText>
INSERT INTO Log(Timestamp,Level,Message,Action,Amount,StackTrace) VALUES(@time_stamp, @level, @message, @action, @amount, @stacktrace);
</commandText>
<!-- database connection parameters -->
<parameter name="@time_stamp" layout="${date}" />
<parameter name="@level" layout="${level:uppercase=true}" />
<parameter name="@message" layout="${message}" />
<parameter name="@action" layout="${event-context:item=Action}" />
<parameter name="@amount" layout="${event-context:item=Amount}" />
<parameter name="@stacktrace" layout="${stacktrace}" />
</target>
</target>
</targets>
<rules>
11 months ago
<!--Min TRACE,DEBUG,INFO,WARN,ERROR,FATAL Max-->
11 months ago
<!--此路由设置了final所以当此路由被匹配到时。不会再匹配此路由下面的路由。未匹配到此路由时才会继续匹配下一个路由-->
<logger name="Microsoft.*" maxlevel="Warning" final="true" />
<logger name="BigDataLogger" writeTo="big" final="true"/>
<logger name="RequRespLogger" writeTo="requResp" final="true"/>
<logger name="*" writeTo="info" minlevel="INFO"/>
<logger name="*" writeTo="error" minlevel="ERROR" />
</rules>
</nlog>