NLog File Target with support for ConcurrentWrites-option where multiple processes can write to the same file.
This is the legacy FileTarget from NLog v5, if unable to use the new optimized FileTarget included with NLog v6.
Notice one must explicit configure ConcurrentWrites="true"
to support concurrent writing to same file.
Alternative consider using the new NLog.Targets.AtomicFile nuget-package.
If having trouble with output, then check NLog InternalLogger for clues. See also Troubleshooting NLog
See the NLog Wiki for available options and examples.
NLog will only recognize type-alias File
when loading from NLog.config
-file, if having added extension to NLog.config
-file:
<extensions>
<add assembly="NLog.Targets.ConcurrentFile"/>
</extensions>
Alternative register from code using fluent configuration API:
LogManager.Setup().SetupExtensions(ext => {
ext.RegisterTarget<NLog.Targets.ConcurrentFileTarget>();
});