Skip to content

Writing to the same file from multiple processes does not function when concurrentWrites="true" and keepFileOpen="true" #1029

@jonreis

Description

@jonreis

NLog version 4.2

Behavior seen: I have an application that spawns child process. Each child process writes to the same NLog log file. We have noticed that some child processes fail to write to the log, particularly when there is a roll-over of the log file, but also sometimes at startup.

Behavior expected: It must be expensive to have to open and close the file, so I would expect the keepFileOpen to work for a concurrent process scenario.

Work Around: It seems if keepFileOpen is set to false instead of true, then things work as expected.

I will paste in a test application that demonstrates this. If you would like a ready to run application, let me know and I will email it to you out of band.

To run the code:

  1. tart the application. This will start up 5 processes
  2. Verify the log file contains entries for all 5
  3. Advance the date on your computer by 1 day
  4. Verify the log file contains entries for all 5. In most cases it will not.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions