This repository has been archived by the owner on Aug 31, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
I known File Sink is currently mostly used in local development, but we also tend to use it in our production environment with fluentd, because this combination is very stable and reliable.
Currently File Sink lacks the file rolling function, which is very important for the production environment. So I want to add file rolling function to File Sink through this pr without breaking changes.
Usage
file rolling is disabled by default, and can be enabled by adding the following arguments:
the rolling function is powered by lumberjack. Becasue
lumberjack.Logger
implmentedio.WriteCloser
interface, so it is easy to replacefile *os.file
withwriter &lumberjack.Logger
.Test Result
run kubernetes-event-exporter with following config:
run following script to generate events and output
./event*.log
status:the result is:
when
event.log
reaches 1M, it is renamed toevent-2020-03-04T10-54-11.451.log
, because backup files are more than 4, the oldest oneevent-2020-03-04T10-03-30.271.log
is deleted.