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

Views: 228
Comments: 0
Like/Unlike: 1
Posted On: 24-Jul-2018 02:53 

Share:   fb twitter linkedin
Smith
Participant
4 Points
1 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

 

0 Comments
  
banner

Blog

Active User (9)

 Log In to Chat