Cysharp / ZLogger

Zero Allocation Text/Structured Logger for .NET with StringInterpolation and Source Generator, built on top of a Microsoft.Extensions.Logging.
MIT License
1.11k stars 79 forks source link

Improvement: Shared Files #130

Closed JKamsker closed 5 months ago

JKamsker commented 6 months ago

When logging from multiple processes into the same file, the file will be corrupted. To prevent that, the file could be locked during the actual write, and the lock could be released after that. I am writing something fairly similar to this and archived over 2 million messages/sec with that approach.

Here is my approach if you want to get some inspiration: https://gist.github.com/JKamsker/0de2d65ba0730d89022e7aea83ca7643

neuecc commented 6 months ago

Serilog's FileSink has shared(use mutex) and it may be a common option required for loggers. I will consider introducing it, thanks.

neuecc commented 5 months ago

I've released 2.3.0, it includes this feature.