mirror of
https://gitee.com/iioter/iotgateway.git
synced 2024-12-02 03:38:01 +08:00
9c71e1a286
2.引入NLog,默认写入本地 3.Driver构造函数增加Logger和Device参数,用于记录日志
35 lines
1.6 KiB
XML
35 lines
1.6 KiB
XML
<?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="./logs/internal-nlog-AspNetCore.txt">
|
|
|
|
<!-- enable asp.net core layout renderers -->
|
|
<extensions>
|
|
<add assembly="NLog.Web.AspNetCore"/>
|
|
</extensions>
|
|
|
|
<!-- the targets to write to -->
|
|
<targets>
|
|
<!-- File Target for own log messages with extra web details using some ASP.NET core renderers -->
|
|
<target xsi:type="File" name="ownFile-web" fileName="./logs/${logger}/${shortdate}/iotgateway.log"
|
|
maxArchiveDays="7"
|
|
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${level:uppercase=true}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}|${callsite}" />
|
|
|
|
<!--Console Target for hosting lifetime messages to improve Docker / Visual Studio startup detection -->
|
|
<target xsi:type="Console" name="lifetimeConsole" layout="${MicrosoftConsoleLayout}" />
|
|
</targets>
|
|
|
|
<!-- rules to map from logger name to target -->
|
|
<rules>
|
|
<!--Output hosting lifetime messages to console target for faster startup detection -->
|
|
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="lifetimeConsole, ownFile-web" final="true" />
|
|
|
|
<!--Skip non-critical Microsoft logs and so log only own logs (BlackHole) -->
|
|
<logger name="Microsoft.*" maxlevel="Info" final="true" />
|
|
<logger name="System.Net.Http.*" maxlevel="Info" final="true" />
|
|
|
|
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
|
|
</rules>
|
|
</nlog> |