Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Nlog不会删除日志文件_C#_Asp.net Mvc_File_Logging_Nlog - Fatal编程技术网

C# Nlog不会删除日志文件

C# Nlog不会删除日志文件,c#,asp.net-mvc,file,logging,nlog,C#,Asp.net Mvc,File,Logging,Nlog,我正在创建一个ASP MVC应用程序。我将此配置文件用于NLOG <?xml version="1.0" encoding="utf-8" ?> 当日志文件大小等于archiveAboveSize时-日志记录停止。删除现有文件时,将创建并写入一个新的日志文件。如何正确创建NLOG的配置文件 看一下 基于大小的文件归档 日志文件达到一定大小后,可以通过将其移动到另一个位置来自动存档。以下配置将创建日志/logfile.txt,一旦主日志文件达到10KB,这些日志将

我正在创建一个ASP MVC应用程序。我将此配置文件用于NLOG

 <?xml version="1.0" encoding="utf-8" ?>


当日志文件大小等于archiveAboveSize时-日志记录停止。删除现有文件时,将创建并写入一个新的日志文件。如何正确创建NLOG的配置文件

看一下

基于大小的文件归档 日志文件达到一定大小后,可以通过将其移动到另一个位置来自动存档。以下配置将创建日志/logfile.txt,一旦主日志文件达到10KB,这些日志将被归档到archives/log.000000.txt',archives/log.000001.txt',archives/log.000002.txt',等等

<?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>

<?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>