Serilog - Unable to open file - File used by another process Error

Viewed 890

I'm using serilog in a .NetCore 3.1 application.

loggerFactory.AddSerilog();
Log.Logger = new LoggerConfiguration().MinimumLevel.Information()
            .WriteTo.File("test-{Date}.txt").CreateLogger();

app.UseSerilogRequestLogging();

When i run a application and try to access file, i'm getting error saying "File cannot be opened because it is being used by another process"

Am i missing any setting to be added?

Update:

Even after adding shared:true - Did not work.

Log.Logger = new LoggerConfiguration().MinimumLevel.Information()
            .WriteTo.Async( o => o.File("test1.txt", shared: true)).CreateLogger();
0 Answers
Related