when serilog is writing the log into file,i cant open that file
See original GitHub issuethis is my code, who can tell me how to set the serilog
Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Information() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .Enrich.FromLogContext() .WriteTo.Console() // .WriteTo.Async(c => c.File("Logs/logs.txt")) .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Debug).WriteTo.File(LogFilePath("Debug"), rollingInterval: RollingInterval.Day, outputTemplate: SerilogOutputTemplate)) .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Information).WriteTo.File(LogFilePath("Information"), rollingInterval: RollingInterval.Day, outputTemplate: SerilogOutputTemplate)) .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Warning).WriteTo.File(LogFilePath("Warning"), rollingInterval: RollingInterval.Day, outputTemplate: SerilogOutputTemplate)) .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Error).WriteTo.File(LogFilePath("Error"), rollingInterval: RollingInterval.Day, outputTemplate: SerilogOutputTemplate)) .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Fatal).WriteTo.File(LogFilePath("Fatal"), rollingInterval: RollingInterval.Day, outputTemplate: SerilogOutputTemplate)) .CreateLogger();
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
You can’t delete a file that’s been locked for writing. There may be a way to tell the File sink not to hold the file open (please DO NOT ENGAGE ME IN CHAT HERE REGARDING THAT!). It’s possible that VS has a Read Only mode that will work even if the file is locked. Visual Studio WILL work. And I will now Work too. Again: Stackoverlow.com please.
I often use Visual Studio Code in the background to view the log file - the log writer will attempt to open the file in Write mode, and the Operating System will prevent more than one thing from doing that; this is likely part of your problem. I hope you got sorted.