Archive nlog files and enable Archive File Compression (Compress the archive files into the zip files)

Views: 11034
Comments: 1
Like/Unlike: 2
Posted On: 24-Jul-2018 02:53 

Share:   fb twitter linkedin
Smith
2890 Points
78 Posts

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

great!


Pratibha
18-Apr-2024 at 22:18
 Log In to Chat