appender: add filter to limit and rotate log files by size #3026
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.
EDIT: after reviewing #2497 in detail I decided to close this one. That PR has more or less what I expected from this feature, so I'll close this one to focus the attention on that PR. Apologies for the noise.
Motivation
The
RollingFileAppender
currently allows you to rotate the log files by time and limit the number of previous files kept on disk. In some environments where the disk capacity is limited, we also need to control and limit the size of the logs.So far, two PR's have been submitted to add this feature: #2904 and #2497. Both try to add a new
Rotation
variant, forcing the user to choose between rotating by time or size, which can limit the UX depending on the needs of the user.What I'd like ideally is to rotate logs on a frequency basis, but also limit the max size of a log file. The main goal though can be achieved with any of the 3 open PR's, which is having the ability to determine the max size of the logs of an application to get a better estimate of the host machine's disk requirements.
Closes #1940
Closes #858
Solution
This PR adds a new filter to limit the size of the logs files, which can be used together with the frequency rotation filter. The first condition to be met will decide how the file is rotated.