Skip to content

Expire session logs older than the retention window - #17

Merged
rodchristiansen merged 1 commit into
mainfrom
log-retention
Aug 20, 2026
Merged

Expire session logs older than the retention window#17
rodchristiansen merged 1 commit into
mainfrom
log-retention

Conversation

@rodchristiansen

Copy link
Copy Markdown
Contributor

Fixes #16.

Logger.Initialize created a new yyyy-MM-dd-HHmmss.log on every run and nothing ever removed one, so C:\ProgramData\ManagedBootstrap\logs grew for the life of the machine — several hundred files after a year of nightly runs.

  • BootstrapMateConstants.LogRetentionDays (30) sits beside the LogDirectory constant it governs.
  • Logger.PruneExpiredLogs runs from Initialize, right after the new log path is chosen.
  • Age comes from last write time, not from parsing the file name. The same directory collects logs written by wrapper scripts that do not follow the timestamped naming, and a name-based sweep would leave those behind forever.
  • Best-effort throughout: a log held open elsewhere is skipped and retried next run, and nothing here can fail a bootstrap.
  • A non-positive LogRetentionDays disables the sweep.

No test project exists in this repo, so this is verified by build and inspection only.

Every run wrote a new timestamped log into ManagedBootstrap\logs and nothing
ever removed one, so the directory grew for the life of the machine -- several
hundred files after a year of nightly runs.

Sweep on Initialize, keyed on last write time rather than the file name: the
same directory collects logs from wrapper scripts that do not use the
timestamped naming, and those need expiring too. Best-effort throughout; a log
held open elsewhere is skipped and retried next run, and no failure here can
stop a bootstrap.
@rodchristiansen
rodchristiansen merged commit e8ba183 into main Aug 20, 2026
2 checks passed
@rodchristiansen
rodchristiansen deleted the log-retention branch August 20, 2026 21:57
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.

Session logs are never expired

1 participant