Skip to content

File name with creation timestamp (a part of the isssue #243) #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

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