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.
Changes proposed in this pull request:
NATS Server 2.9 has
logfile_size_limit
option which allows the operator to set an optional byte limit on the NATS Server log file which when met causes a "rotation" such that the current log file is renamed (original file name appended with a time stamp to nanosecond accuracy) and a new log file is instantiated.This PR is a new
logfile_max_num
companion option (aliaslog_max_num
) which allows the operator to designate that the server should prune the total number of log files -- the currently active log file plus backups -- to the maximum setting.A max value of
0
(the implicit default) or a negative number has meaning of unlimited log files (no maximum) as this is an opt-in feature.A max value of
1
is effectively a truncate-only logging pattern as any backup made at rotation will subsequently be purged.A max value of
2
will maintain the active log file plus the latest backup. And so on...When enabled, backup log deletion is evaluated inline after each successful rotation event. To be considered for log deletion, backup log files MUST adhere to the file naming format used in log rotation as well as agree with the current
logfile
name and location. Any other files or sub-directories in the log directory will be ignored. E.g. if an operator makes a manual copy of the log file tologfile.bak
that file will not be evaluated as a backup.Typical use case:
This feature is useful in a constrained hosting environment for NATS Server, for example an embedded, edge-compute, or IoT device scenario, in which more featureful platform or operating system log management features do not exist or the complexity is not required.