-
Notifications
You must be signed in to change notification settings - Fork 1.4k
GZip File Target
Rolf Kristensen edited this page Jul 2, 2025
·
2 revisions
Writes LogEvents to file using GZip compression, by extending the standard NLog File Target.
Platforms Supported: All - Requires nuget-package NLog.Targets.GZipFile
<targets>
<target xsi:type="GZipFile"
name="string"
fileName="Layout"
layout="Layout"
compressionLevel="CompressionLevel"
keepFileOpen="boolean"
enableArchiveFileCompression="boolean"
archiveOldFileOnStartup="boolean"
/>
</targets>
- fileName - Name of the file to write to. Layout Required.
-
layout - Text to be rendered. Layout Required.
Default:
${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}
-
compressionLevel - File compression level
-
Optimal
- Optimize for small file size -
Fastest
- Optimize for speed -
NoCompression
- Disables GZip compression
-
-
keepFileOpen - Disables GZip compression when configured to
false
. Default:true
-
archiveOldFileOnStartup - Disables GZip compression when configured to
false
. Default:true
Also inherits all parameters from the standard File-Target.
- Troubleshooting Guide - See available NLog Targets and Layouts: https://nlog-project.org/config
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
- Articles about NLog
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json