使用Visual Studio 2013 ASP .NET MVC 5,我有这个.txt文件,其中记录了我的Web应用程序中捕获的异常(使用NLog)。每个月,我都希望将该文件存档到我项目中的不同文件夹中。我怎样才能做到这一点?感谢
答案 0 :(得分:1)
我认为这可以做到
<?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"
autoReload="true" internalLogFile="c:/logs/nlog_ex.txt" internalLogLevel="Debug">
<!--
See http://nlog-project.org/wiki/Configuration_file
for information on customizing logging rules and outputs.
-->
<targets>
<target xsi:type="File"
name="exceptions"
encoding="utf-8"
lineEnding="Default"
layout="${longdate} - ${message}"
archiveFileName="c:/logs/${date:format=yyyy-MM}/exceptions.txt"
archiveNumbering="Sequence"
archiveEvery="Month"
fileName="c:/logs/exceptions.txt"
deleteOldFileOnStartup="false"
enableFileDelete="true"
createDirs="true"
concurrentWrites="true"
autoFlush="true"
keepFileOpen="false"
/>
</targets>
<rules>
<!-- add your logging rules here -->
<logger name="*" minlevel="Info" writeTo="exceptions" />
</rules>
</nlog>
我使用了domcumentation。