Archive nlog files and enable Archive File Compression (Compress the archive files into the zip files)
Introduction
In the default/normal nlog configuration, log files generated on the daily basis and never delete. If you want only x days's log files exists and other truncated then you need to use the nlog archive configuration.
Example
The following configuration will keep 10 days archived log files with compression(zipped). And will archive daily basis
<targets>
<!-- write logs to file -->
<target xsi:type="File" name="allfile"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="10"
archiveFileName="${basedir}\temp\Archive\nlog-all-${shortdate}.zip"
enableArchiveFileCompression="true"
fileName="${basedir}\temp\nlog-all-${shortdate}.log"
layout="${longdate}|${event-
properties:item=EventId.Id}|${logger}|${uppercase:${level}}|${message} ${exception}" />
</targets>
References
https://github.com/nlog/NLog/wiki/File-target
1 Comments
Blog
Active User (0)
No Active User!
great!
Pratibha
18-Apr-2024 at 22:18