How does one configure Serilog so it overwrites the file every time the program executes?
Code
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.ColoredConsole()
.WriteTo.File("c:\\Logs\\myapp.log")
.CreateLogger();
It doesn't hurt to append the entry logs of the new execution but during development is convenient just getting the current ones.
As suggested in the comment above, deleting the file with System.IO.File.Delete()
is the way to go:
File.Delete("c:\\Logs\\myapp.log");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With