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>