Designs .NET structured logs, traces, metrics, correlation, and telemetry redaction around operational questions. Use for service observability; do not use for runtime dump/counter investigations (use dotnet-diagnostics) or code correctness review.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Logging Observability?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/k4ndev-logging-observability)
---
name: logging-observability
description: Designs .NET structured logs, traces, metrics, correlation, and telemetry redaction around operational questions. Use for service observability; do not use for runtime dump/counter investigations (use dotnet-diagnostics) or code correctness review.
---
# Logging and Observability
## Purpose
Make production behavior diagnosable with useful, privacy-safe telemetry at an operationally sustainable cost.
## Scope
`ILogger`, structured logging, scopes, distributed tracing, metrics, OpenTelemetry instrumentation, correlation, redaction, retention, and alert signals.
## When to use
- A service lacks actionable logs/metrics/traces or loses context across HTTP/messaging.
- User asks how to instrument or safely diagnose an operational question.
## Do not use for
- Collecting process dumps/counters/traces to solve a live incident: use `dotnet-diagnostics`.
- Broker processing reliability: use `messaging-patterns`.
- Audit/security analysis of sensitive data flow: coordinate `security-audit`.
## Required context
Identify the question operators need to answer, deployment/logging backend, sampling/retention, privacy policy, service boundaries, existing `Activity`/metrics, and volume/cost constraints.
## Workflow
1. Define a specific question (e.g. which dependency causes checkout latency) before adding telemetry.
2. Use structured templates and stable event names; keep values as properties instead of interpolating them into the message.
3. Use appropriate levels and log once where failures are classified/handled; avoid catch-log-rethrow at every layer.
4. Propagate trace/correlation context across HTTP and message boundaries; prefer OpenTelemetry-compatible instrumentation where supported.
5. Keep metric labels bounded (route template, outcome class); never label by user ID, request ID, URL, or arbitrary exception text.
6. Redact credentials, tokens, connection strings, payment data, and unnecessary PII; check logs, baggage, exceptions, and test fixtures.
7. Estimate event volume, sampling, retention, access control, and alert thresholds; verify telemetry with a test/exporter or local trace.
## Decision rules
- Logs describe discrete events; metrics are aggregatable bounded series; traces connect causal work. Do not substitute one blindly for another.
- Cancellation is usually not an application error; avoid error-level noise for expected request cancellation.
- Add instrumentation only when it answers a named question or supports a defined SLO/security audit.
## Expected output format
Show the operational question, event/metric/span design, privacy/cardinality rules, code sample, verification method, and cost/retention assumptions.
## Common mistakes
- Interpolated/unstructured logs, secrets in scopes, high-cardinality labels, duplicate exception logging, or claiming OpenTelemetry is automatically configured by adding a package.
## Edge cases
- Sampling may remove spans needed for rare errors; use appropriate tail/head sampling and error tagging strategy.
- User-controlled baggage can leak data and inflate telemetry; validate propagation and size.
- Log message template properties are not automatically redacted by every provider; verify sink configuration.
## Examples
See [observability examples](examples.md) for stable structured events and bounded metric labels.
## Test scenarios
- Positive: “Correlate an HTTP request with an outbox message without putting user IDs in metric labels.”
- Negative: “A process has a 2 GB managed heap; capture a dump” routes to `dotnet-diagnostics`.
- Boundary: security audit finds a token in logs; `security-audit` owns risk assessment and this skill recommends safe instrumentation/redaction.
## Related skills
`dotnet-diagnostics`, `security-audit`, `messaging-patterns`, `aspnetcore-patterns`, `performance-review`.