-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Atomic File Target
Rolf Kristensen edited this page Sep 12, 2025
·
6 revisions
Writes LogEvents to file using operating system API for atomic file appending (O_APPEND), so multiple processes can write concurrently to the same file, by extending the standard NLog File Target.
Platforms Supported: NET8 or .NET Framework - Requires nuget-package NLog.Targets.AtomicFile
<targets>
<target xsi:type="AtomFile"
name="string"
fileName="Layout"
layout="Layout"
concurrentWrites="boolean"
keepFileOpen="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}
-
concurrentWrites - Whether to enable atomic file appends. Default:
true -
keepFileOpen - Disables atomic file appends when configured to
false. Default:true
Also inherits all parameters from the standard File-Target.
Linux requires platform specific publish for Mono.Posix.NETStandard:
dotnet publish with --framework net8.0 --configuration release --runtime linux-x64
- 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