2
在我的一些程序中,我有30天的輪轉,預計有幾個月的多個條目,但只有30個日誌文件。在其他程序中,我只有一天的日誌文件,但總共只有30個日誌文件。我想要的僅僅是最近30天的30個日誌文件的日誌文件條目。我想我不知道我錯過了什麼。NLog歸檔配置
昨天我的一個日誌文件在程序啓動時被覆蓋,所以我丟失了能告訴我發生了什麼的數據。那麼我的第二個問題是,歸檔只是刪除不適合模式的文件,或者實際上是否需要將日誌文件放在某個位置?什麼是歸檔?這是我的nlog.config:
<?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">
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<variable name="LogDir" value="${specialfolder:folder=MyDocuments}/MyApp/Log"/>
<variable name="LogDay" value="${date:format=dd}"/>
<targets async="true">
<!-- add your targets here -->
<target name="LogTarget1"
xsi:type="File"
fileName="${LogDay}.log"
encoding="utf-8"
maxArchiveFiles="30"
archiveNumbering="Sequence"
archiveAboveSize="52428800"
archiveFileName="${LogDay}.{#######}.log"
layout="${date:format=MM/dd/yyyy HH\:mm\:ss}|${level:uppercase=true}|${message}" />
</targets>
<rules>
<!-- add your logging rules here -->
<logger name="*" minlevel="Trace" writeTo="LogTarget1" />
</rules>
</nlog>