Derek Collison 22514a033f Add logfile_max_num feature (#4548)
### 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 (alias
`log_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...

> The currently active log file is never purged. Only backups are
purged.

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 to `logfile.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.
2023-09-18 09:02:41 -07:00
2023-09-15 16:12:46 -04:00
2021-07-13 10:07:31 +02:00
2022-08-03 14:01:55 -07:00
2023-09-06 13:20:10 -04:00
2018-03-15 11:38:25 -07:00
2022-08-16 16:48:00 -06:00
2023-09-13 16:24:30 +01:00
2023-09-13 16:24:30 +01:00
2020-11-10 10:40:28 -06:00
2018-03-15 22:31:07 -07:00
2023-03-17 15:09:50 -07:00
2020-06-22 11:10:49 -05:00
2023-09-06 16:08:07 -04:00

NATS Logo

NATS is a simple, secure and performant communications system for digital systems, services and devices. NATS is part of the Cloud Native Computing Foundation (CNCF). NATS has over 40 client language implementations, and its server can run on-premise, in the cloud, at the edge, and even on a Raspberry Pi. NATS can secure and simplify design and operation of modern distributed systems.

License Build Release Slack Coverage Docker Downloads CII Best Practices

Documentation

Contact

  • Twitter: Follow us on Twitter!
  • Google Groups: Where you can ask questions
  • Slack: Click here to join. You can ask question to our maintainers and to the rich and active community.

Contributing

If you are interested in contributing to NATS, read about our...

Roadmap

The NATS product roadmap can be found here.

Security

Security Audit

A third party security audit was performed by Cure53, you can see the full report here.

Reporting Security Vulnerabilities

If you've found a vulnerability or a potential vulnerability in the NATS server, please let us know at nats-security.

License

Unless otherwise noted, the NATS source files are distributed under the Apache Version 2.0 license found in the LICENSE file.

Description
No description provided
Readme Apache-2.0 33 MiB
Languages
Go 99.6%
Shell 0.4%