Skip to content
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

Date Based File Archiving #241

Merged
1 commit merged into from
Aug 29, 2013
Merged

Date Based File Archiving #241

1 commit merged into from
Aug 29, 2013

Conversation

mkaltner
Copy link
Contributor

I made a few minor changes that allows archiving based on dates instead of rolling/sequential numbering.
The changes have minimal impact and work with the existing code/parameters as much as possible.
I found many posts/bug reports about deleting archive files with dates in the file name as I was having the same issue.
I've been testing this for a couple days and is working as expected.

Sample output showing archive files with datetime and maxArchiveFiles of 2 (The log file for 4:29 has been deleted):
image

Config used to achieve the results in the previous screenshot (archiveDateFormat is optional and will be generated based on archiveEvery setting if not specified):
image

archiveNumbering can be set to Date.
archiveFileName should contain the standard {#} placeholder for numbers which will now be used to store the archive date.
archiveDateFormat can optionally be specified for a custom date format.
maxArchiveFiles will be honored and old files deleted when applicable (based on archive period)
@ghost
Copy link

ghost commented Jul 17, 2013

Thanks for the pull request I'll take a look at it

@realityexists
Copy link

Date-based archiving would be a useful feature for me. Thanks, mkaltner. I hope this gets merged soon.

ghost pushed a commit that referenced this pull request Aug 29, 2013
Date Based File Archiving
@ghost ghost merged commit 3d2aa54 into NLog:master Aug 29, 2013
@Doomjunky
Copy link

I think you missused the archiveNumbering attribute. This attribute describes the schema how to number the archived files (Sequence|Rolling). This numbering strategies can be applied on dates too, but "dateNumbering" is not a numbering schema.

What you want is a trigger to archive a file. Here is my idea: a archiveTrigger attribute. Which takes values of Size|Date|Run. This attribute describes the trigger that creates a new file and archives the old file.

@ghost
Copy link

ghost commented Jan 17, 2014

Thanks for the feedback, it sounds reasonable to do what you say, and I'll
will look into this.
But it would be a breaking change, so it won't be at least until version 4,
as 3 is in the final stage.

@mkaltner
Copy link
Contributor Author

While I do agree with Doomjunky, Xharze's comment is the reason why I chose to implement the change the way I did. Sometimes it's better to minimally alter existing functionality versus making major changes to the project. That's not to say it couldn't be implemented better, architecturally speaking.

@alexeevk
Copy link

alexeevk commented Jun 4, 2014

Thank you Mike!

@swapneeld
Copy link

👍

@304NotModified 304NotModified added the file-archiving Issues with archiving with the file target label Aug 26, 2019
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
file-archiving Issues with archiving with the file target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants