-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Log rotation #5778
Log rotation #5778
Conversation
+1 |
// Use year-month-date for readability, unix time to make the file name unique with second precision | ||
now := time.Now() | ||
rotatedFilename := fmt.Sprintf(w.filenameRotationTemplate, now.Format(DateFormat), strconv.FormatInt(now.Unix(), 10)) | ||
if err = os.Rename(w.filename, rotatedFilename); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe compress the rotated file?
https://www.dotnetperls.com/compress-go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, mind opening a new feature request for compressing the rotated files since this pr has been merged, thanks.
Concerns #3393
I took the code from #5547 as a basis and did the following:
This PR uses the new file writer for logging purposes only, but it can be easily plugged in the output file plugin.
Required for all PRs: