Answer the question
In order to leave comments, you need to log in
How to delete old logs (NLog)?
Unable to delete old logs, does anyone know what could be the problem?
<target
name="infoLog"
xsi:type="File"
fileName="${logDir}/info.{#}.txt"
layout="${info}"
archiveFileName="${logDir}/Log.info.{#}.txt"
archiveEvery="day"
archiveNumbering="Rolling"
maxArchiveFiles="2"
concurrentWrites="true" />
<target
name="errorLog"
xsi:type="File"
fileName="${logDir}/error.{#}.txt"
layout="${error}"
archiveFileName="${logDir}/Log.error.{#}.txt"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="2"
concurrentWrites="true" />
Answer the question
In order to leave comments, you need to log in
You've done almost everything right. But,
1. For infoLog, archiveEvery="day" was specified, but you need to capitalize it.
2. maxArchiveFiles is responsible for the number of archives (these are files that are created after the current log is filled).
Here is an example target:
<target
name="infoLog"
xsi:type="File"
fileName="${logDir}/Log.info.txt"
archiveFileName="${logDir}/Log.info.{#}.txt"
archiveEvery="Minute"
archiveNumbering="Rolling"
maxArchiveFiles="2"
concurrentWrites="true" />
for (int i = 0; i < 100; i++)
{
logger.Info("{0} Log Test", i);
Thread.Sleep(TimeSpan.FromSeconds(20));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question