[英]Nlog does not delete the log file
I am creating an application ASP MVC. 我正在创建一个应用程序ASP MVC。 I use for NLOG this configuration file
我使用NLOG这个配置文件
<?xml version="1.0" encoding="utf-8" ?>
<target name="file"
xsi:type="File"
layout="${date}|${level}|${message}"
fileName="C:\Log\log.txt"
createDirs="true"
archiveEvery="Day"
concurrentWrites="true"
archiveFileName="CopyLogs\${LogFileName}.{#####}.${LogFileExtension}"
archiveAboveSize="500000" maxArchiveFiles="200"
archiveNumbering="Rolling"
deleteOldFileOnStartup="false"
/>
</targets>
<rules>
<!-- add your logging rules here -->
<logger name="*" minlevel="Info" writeTo="file" />
</rules>
</nlog>
When log file size is equal to archiveAboveSize - logging stops. 当日志文件大小等于archiveAboveSize时-日志记录停止。 When I delete an existing file a new log file is created and written.
当我删除现有文件时,将创建并写入一个新的日志文件。 How do I properly create a configuration file for NLOG?
如何为NLOG正确创建配置文件?
Have a look at the NLog Wiki 看看NLog Wiki
Log files can be automatically archived by moving them to another location after reaching certain size. 日志文件达到一定大小后,可以通过将其移动到另一个位置来自动存档。 The following configuration will create logs/logfile.txt which will be archived to archives/log.000000.txt', archives/log.000001.txt', archives/log.000002.txt' and so on once the main log file reaches 10KB.
以下配置将创建logs / logfile.txt,一旦到达主日志文件,该文件将被归档到archives / log.000000.txt',archives / log.000001.txt',archives / log.000002.txt'等。 10KB。
<?xml version="1.0" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="file" xsi:type="File"
layout="${longdate} ${logger} ${message}"
fileName="${basedir}/logs/logfile.txt"
archiveFileName="${basedir}/archives/log.{#####}.txt"
archiveAboveSize="10240"
archiveNumbering="Sequence"
concurrentWrites="true"
keepFileOpen="false"
encoding="iso-8859-2" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="file" />
</rules>
</nlog>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.