日志滚动保留7天

This commit is contained in:
iioter 2022-09-14 20:51:12 +08:00
parent c9498db55a
commit aba6f7b2da
2 changed files with 7 additions and 5 deletions

View File

@ -13,9 +13,11 @@
<!-- 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"
<target xsi:type="File" name="ownFile-web" fileName="./logs/${shortdate}/${shortdate}_${level}.log"
archiveEvery="Hour" archiveAboveSize="20971520"
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}" />
maxArchiveFiles="10"
layout="${longdate}|${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}" />
@ -27,9 +29,9 @@
<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="Microsoft.*" minlevel="Error" final="true" />
<logger name="System.Net.Http.*" minlevel="Error" final="true" />
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
<logger name="*" minlevel="Info" writeTo="ownFile-web" />
</rules>
</nlog>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 13 KiB