Skip to content
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

Configuration Syntax

<targets>
  <target xsi:type="AtomFile"
          name="string"
          fileName="Layout"
          layout="Layout"
          concurrentWrites="boolean"
          keepFileOpen="boolean"
  />
</targets>

Parameters

  • 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 Support

Linux requires platform specific publish for Mono.Posix.NETStandard:

dotnet publish with --framework net8.0 --configuration release --runtime linux-x64

Clone this wiki locally