# Logging Telemetry

> Configure structured logging and telemetry for the .NET 8 WPF widget host app using Serilog, ETW, and Application Insights. Use when wiring logging sinks, correlation IDs, PII redaction, error reporting, and diagnostics exports.

- Skill: `majiayu000/logging-telemetry` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add majiayu000/logging-telemetry`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/logging-telemetry/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/logging-telemetry

---


# 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

1. Define log levels and categories (UI, sync, data, widgets).
2. Configure Serilog sinks and enrichers.
3. Add correlation IDs per user action or sync cycle.
4. Redact or hash PII before logging.
5. 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.md` for sink and enricher setup.
- `references/appinsights.md` for telemetry wiring.
- `references/pii-handling.md` for redaction rules.
- `references/correlation.md` for correlation IDs and scopes.

