fix(logging): cap rolling debug log file size to prevent disk exhaustion - #1473
Open
jonnyarndt wants to merge 4 commits into
Open
fix(logging): cap rolling debug log file size to prevent disk exhaustion#1473jonnyarndt wants to merge 4 commits into
jonnyarndt wants to merge 4 commits into
Conversation
Add configurable fileSizeLimitBytes + rollOnFileSizeLimit to the Serilog file sink so the daily rolling log set cannot fill constrained storage (e.g. RMC4 with \user on a small removable USB drive). Caps persist in CrestronDataStore and are settable via the new applogfilecap console command (effective next restart), with conservative appliance defaults (4 MB x 7 files). Refs #1472
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses disk-exhaustion risk from unbounded daily Serilog rolling debug logs by introducing a per-file size cap (rolling on size) and persisting configurable caps (size + retained file count) in CrestronDataStore, with a console command to view/update them.
Changes:
- Add
fileSizeLimitBytes+rollOnFileSizeLimit: trueto the Serilog file sink and replace hard-coded retained count with a persisted setting. - Introduce persisted configuration keys/defaults for log file size cap and retained-file count.
- Add the
applogfilecapconsole command to view/set caps (effective on next restart).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ogfilecap args Addresses Copilot review on #1473: clamp CDS-loaded fileSizeLimitBytes/retainedCount to the enforced floors (65536 bytes / 1 file) at startup so a stale small stored value cannot cause pathological rolling, and reject >2 console tokens to prevent silent misconfiguration.
…te limit AddNewConsoleCommand throws ArgumentOutOfRangeException (help >79 bytes), faulting Debug's type initializer and aborting the ControlSystem ctor (Program Stopped). Trim help text 93->71 bytes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1472
Problem
On constrained storage (e.g. an RMC4 where Crestron relocates
\useronto a small removable USB drive), the Serilog rolling debug log file could grow without bound. The.WriteTo.File(...)sink usedrollingInterval: Day+retainedFileCountLimitbut had nofileSizeLimitBytes, so a single day'sglobal-log.logcould fill the drive and take the processor down.Fix
fileSizeLimitBytes+rollOnFileSizeLimit: trueto the file sink so each rolled file is bounded and rolls on size as well as by day.CrestronDataStore, with conservative platform defaults:applogfilecapconsole command to view/set the caps at runtime (takes effect on next program restart, since the Serilog file-size limit is fixed at sink construction).Compatibility
Backward compatible — defaults preserve the existing daily-rolling behavior while adding an upper bound. No API breakage.
Note on base version
Authored and build-verified against tag
v2.39.0(0 errors) because Crestron SDK builds after v2.39.0 currently have unrelated issues in our environment. The change itself is version-agnostic (Serilog.Sinks.File 5.0.0 supports these parameters on both lines). It may need a rebase/manual apply ontomain; happy to adjust the base branch if the maintainers prefer a maintenance line.