serilog-sinks-file icon indicating copy to clipboard operation
serilog-sinks-file copied to clipboard

How do I create a new file everytime my app is started?

Open Urganot opened this issue 2 years ago • 1 comments

Hi I want to use rolling files with interval per day. But also If the app has to be restarted, it should create a new log file. Is this possible? Also, is it possible to get the file name after the logger has started?

Urganot avatar May 20 '22 16:05 Urganot

Hi, thanks for your message.

Not sure about the first question, may be one for Stack Overflow as it's likely someone's had this need in the past, nothing I can think of here, though.

For your second question, I believe https://github.com/serilog/serilog-sinks-file/issues/129 is an existing discussion.

nblumhardt avatar May 20 '22 21:05 nblumhardt

Creating a new log file every launch is useful in client applications, practical examples such as Minecraft

2A5F avatar Jul 05 '23 08:07 2A5F

@2A5F to create a new file every time the app is started, you can e.g. generate a filename using a GUID. This issue is about combining file-per-launch with another rolling policy (such as per day). HTH!

nblumhardt avatar Jul 05 '23 08:07 nblumhardt

@nblumhardt how archive/rolling previous log files using guid?

2A5F avatar Jul 05 '23 08:07 2A5F

Minecraft is archived like this image I think it's per day

2A5F avatar Jul 05 '23 08:07 2A5F

Closing as stale - ideally questions lke this would be logged on stack overflow - anyone that has the time and interest to follow this repo providing help will also monitor the stack overflow serilog tag (and many more people will see it and/or answer there as the audience is so much broader)

bartelink avatar Oct 19 '23 09:10 bartelink