serilog / serilog-sinks-async

An asynchronous wrapper for Serilog sinks that logs on a background thread
Apache License 2.0
231 stars 30 forks source link

Unable to open file even after adding shared attribute #61

Closed abhishek-v-github closed 4 months ago

abhishek-v-github commented 4 years ago

.NetCore 3.1 - File cannot be opened after staring a application. Error: File cannot be used because it is being used by another process.

loggerFactory.AddSerilog(); Log.Logger = new LoggerConfiguration().MinimumLevel.Information() .WriteTo.Async( o => o.File("test1.txt", shared: true)).CreateLogger(); app.UseSerilogRequestLogging();

chtenb commented 3 years ago

That means that another handle to that file has been opened with exclusive permissions. The shared flag doesn't allow to bypass OS-level restrictions, it merely ensures that the logger itself doesn't acquire and exclusive lock. Does this only occur when using the Async sink?