【发布时间】:2020-11-12 10:20:38
【问题描述】:
我在 NLog.config 中有 int 变量
<variable name="logLifetime2" value="5"/>
但是当我在maxArchiveDays="${logLifetime2}" 中使用它时出现错误。 maxArchiveDays 将我的变量视为字符串。
<variable name="logLifetime2" value="5"/>
<targets>
<target name="Global" xsi:type="File"
fileName="Logs/GlobalLog.txt"
archiveNumbering="Date"
enableArchiveFileCompression="true"
archiveFileName="Archive/IPSlog.{#}.zip"
archiveDateFormat="yyyy-MM-dd"
maxArchiveDays="${logLifetime2}"
archiveEvery="Day" />
</targets>
如何在NLog.Config中创建int变量?
【问题讨论】:
-
你能显示你的 NLog.config 的全部内容吗?你用的是什么版本的 NLog?在 NLog.config 中使用 NLog-config-variables 时,它们会充当逐字复制并且可以正常工作。
-
<variable name="logLifetime2" value="5"/> <targets> <target name="Global" xsi:type="File" fileName="Logs/GlobalLog.txt" archiveNumbering="Date" enableArchiveFileCompression="true" archiveFileName="Archive/IPSlog.{#}.zip" archiveDateFormat="yyyy-MM-dd" maxArchiveDays="${logLifetime2}" archiveEvery="Day" />我使用最后一个 nlog 块包。我无法发送所有 Nlog.config,因为有字符限制 -
当其他人在您的问题中发布有关缺少详细信息的 cmets 时。那么最好只编辑您的问题,并在问题中包含缺少的详细信息。