Skip to content

Persist the tentacle agent log to a rotated file under the service#426

Merged
ppXD merged 1 commit into
mainfrom
fix/windows-persistent-agent-log
Jun 10, 2026
Merged

Persist the tentacle agent log to a rotated file under the service#426
ppXD merged 1 commit into
mainfrom
fix/windows-persistent-agent-log

Conversation

@ppXD

@ppXD ppXD commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • The tentacle's Serilog logger wrote to the console only. A Windows-SCM-launched service has no console — writes go to NUL — so the agent's entire runtime log was lost, leaving operators nothing to inspect after a failure. The only Windows-persistent file (the SCM-startup diagnostic) was append-only with no size cap.
  • Add a size-rotated Serilog file sink (50 MB × 5 retained files) via a new testable TentacleLogging helper, gated to the managed-service launch (ShouldRunUnderScm). Short-lived CLI commands (version, register, …) stay console-only so they don't litter a log file per invocation. On Linux/systemd the console is already captured by journald, so the sink targets the Windows-service gap specifically. Directory creation is best-effort — a log file can never block the service from starting.
  • Bound the separate append-only SCM-startup diagnostic log with a single-generation size rotation (RotateIfOversized, 1 MB → .old).
  • Non-breaking / additive: console behaviour (stderr routing, output template) is unchanged; the file sink is purely additive and only active for the running service. Adds the Serilog.Sinks.File package.

Test plan

  • Unit: operator-visible constants pinned (50 MB / 5 files / tentacle.log / logs / 1 MB SCM cap); ResolveAgentLogPath under {system-config-dir}/logs
  • Unit: file-sink off → no file written (CLI path); file-sink on → persistent log written + contains the message
  • Unit: real rolling-file rotation proven (tiny size override → multiple rolled files, capped at the retained-count limit)
  • Unit: RotateIfOversized under-limit no-op / over-limit → .old + truncate / missing-file no-throw
  • Regression: Squid.Tentacle.Tests Core/Entry/Scm 102/102 green; full suite green except 5 disk-gated RunningScriptReporterTests that fail on a near-full dev disk (DiskSpaceChecker 10% floor — environmental, branch-independent, untouched by this change; passes on CI)
  • dotnet build Squid.sln 0 errors

@ppXD ppXD added this to the 1.8.17 milestone Jun 10, 2026
The tentacle logger wrote to the console only. A Windows-SCM-launched
service has no console (writes go to NUL), so its entire runtime log was
lost — operators had nothing to inspect after a failure. The single
Windows-persistent file, the SCM-startup diagnostic, was append-only with
no size cap.

Add a size-rotated Serilog file sink (50 MB x 5 files) gated to the
managed-service launch, written under {system-config-dir}/logs. Short-lived
CLI commands stay console-only so they don't litter a log file per
invocation; on Linux journald already persists the console, so the sink
targets the Windows-service gap. Best-effort directory creation never blocks
service start. Also bound the append-only SCM-startup diagnostic with a
single-generation size rotation.
@ppXD
ppXD force-pushed the fix/windows-persistent-agent-log branch from cd14aef to b01e58e Compare June 10, 2026 10:04
@ppXD
ppXD merged commit 4097f95 into main Jun 10, 2026
15 checks passed
@ppXD
ppXD deleted the fix/windows-persistent-agent-log branch June 10, 2026 10:10
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.

1 participant