Logging Telemetry
Overview
Set up structured logs and telemetry that are safe, correlated, and useful for diagnosing widget issues.
Constraints
- .NET 8
- Serilog for structured logging
- ETW for local diagnostics
- Application Insights for telemetry
Definition of done (DoD)
- Serilog configured with file sink (rolling, 7-day retention)
- Correlation IDs present on user-initiated actions
- No PII or secrets in logs (verify before merge)
- Structured properties used instead of string interpolation
- Application Insights wired when connection string available
- Log levels appropriate (Debug for verbose, Warning+ for production noise)
Workflow
- Define log levels and categories (UI, sync, data, widgets).
- Configure Serilog sinks and enrichers.
- Add correlation IDs per user action or sync cycle.
- Redact or hash PII before logging.
- Wire Application Insights for events, traces, and exceptions.
Guidance
- Do not log secrets or full payloads.
- Prefer structured properties over string interpolation.
- Keep noisy logs at Debug.
References
references/serilog.mdfor sink and enricher setup.references/appinsights.mdfor telemetry wiring.references/pii-handling.mdfor redaction rules.references/correlation.mdfor correlation IDs and scopes.