Skip to content

Conversation

AlexH1978
Copy link

File name with creation timestamp

For the fileSizeLimitBytes parameter, the dateTimeFormatFileName parameter can also be set to obtain the creation timestamp in the file name.
Example of possible formats:

  • yyyy-MM-dd_HH-mm-ss
  • yyyyMMddHHmmss
  • dd_MM_yyyy-HH_mm_ss
  • ...
    .WriteTo.File("log-.txt", fileSizeLimitBytes: 1024, dateTimeFormatFileName: "yyyy-MM-dd_HH-mm-ss")

If the file limit occurs in the same second as the last file was created, a counter is appended.
This will create a file set like:

log-2025-06-20_17-16-35.txt
log-2025-06-20_20-43-16.txt
log-2025-06-20_20-43-16_001.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant