Skip to content

fix(logging): cap rolling debug log file size to prevent disk exhaustion - #1473

Open
jonnyarndt wants to merge 4 commits into
mainfrom
fix-capEssentialsLogGrowth
Open

fix(logging): cap rolling debug log file size to prevent disk exhaustion#1473
jonnyarndt wants to merge 4 commits into
mainfrom
fix-capEssentialsLogGrowth

Conversation

@jonnyarndt

@jonnyarndt jonnyarndt commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #1472

Problem

On constrained storage (e.g. an RMC4 where Crestron relocates \user onto a small removable USB drive), the Serilog rolling debug log file could grow without bound. The .WriteTo.File(...) sink used rollingInterval: Day + retainedFileCountLimit but had no fileSizeLimitBytes, so a single day's global-log.log could fill the drive and take the processor down.

Fix

  • Add fileSizeLimitBytes + rollOnFileSizeLimit: true to the file sink so each rolled file is bounded and rolls on size as well as by day.
  • Make both the size cap and the retained-file count configurable and persisted in CrestronDataStore, with conservative platform defaults:
    • Appliance: 4 MB × 7 files
    • Server: 16 MB × 14 files
  • Add the applogfilecap console 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 onto main; happy to adjust the base branch if the maintainers prefer a maintenance line.

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
Copilot AI lite review requested due to automatic review settings August 29, 2026 18:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: true to 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 applogfilecap console 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.

Comment thread src/PepperDash.Core/Logging/Debug.cs Outdated
Comment thread src/PepperDash.Core/Logging/Debug.cs
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Serilog missing fileSizeLimitBytes — disk space exhaustion for 4-Series appliance

2 participants