بنقرة واحدة
logging-best-practices
Define a structured logging convention for a service or library.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Define a structured logging convention for a service or library.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Review code changes and report issues by severity with actionable fixes.
Sharpen a fuzzy intention into one measurable objective string that drives the rest of the work.
Convert a Prompt Flow PRS pipeline submission to run a Microsoft Agent Framework workflow.
Build a Model Context Protocol (MCP) server that lets an LLM call into external tools and resources.
Summarize PDF documents into concise bullet-point digests.
Bump a dependency version across a pnpm workspace and update lockfile.
| slug | logging-best-practices |
| name | Logging Best Practices |
| version | 0.1.0 |
| description | Define a structured logging convention for a service or library. |
| category | dev-tools |
| tags | ["logging","observability","structured","debugging"] |
| inputs | [{"name":"runtime","type":"string","required":true,"description":"Language or framework"},{"name":"sensitive_fields","type":"array","required":false,"description":"Fields that must be redacted"}] |
| output | {"format":"markdown","description":"Log levels, field schema, redaction rules, and sample entries."} |
| author | badhope |
| license | MIT |
| created | "2026-06-21T00:00:00.000Z" |
| updated | "2026-06-21T00:00:00.000Z" |
Bootstrapping observability, onboarding a new service, or standardizing logs across a team.
State the runtime and list any fields that must never appear in logs.
A convention doc with levels, required fields, redaction rules, and sample log lines.
Create a structured logging convention for the given runtime.
Include:
1. Log levels and when to use each (DEBUG, INFO, WARN, ERROR)
2. Required base fields: timestamp (ISO8601), level, service, trace_id, span_id
3. Message style: sentence case, no interpolation, static keys
4. Redaction: how to handle the listed sensitive fields
5. Context propagation: request-scoped fields, thread-local / async context
6. Performance: when to sample, when to avoid logging in hot paths
7. Three sample log entries (INFO start, WARN degraded, ERROR failure)
Output format:
## Levels
...
## Base Schema
...
## Redaction
...
## Samples
...
Avoid vendor-specific logger syntax unless it is the runtime's de-facto standard.
Input:
runtime: Go
sensitive_fields: [password, ssn, token, cvv]
Output:
## Levels
- DEBUG: per-request details, sampled to 1% in production
- INFO: state changes and handoffs
- WARN: recoverable degradation
- ERROR: failed requests requiring human review
## Base Schema
`{time, level, msg, svc, trace_id, span_id, duration_ms}`
## Redaction
Mask values for keys matching `*password*`, `*token*`, `*ssn*`, `*cvv*`; replace with `[REDACTED]`.
These are the bugs that bite every new user. Check them before shipping:
Logging sensitive data: Accidentally logging passwords, tokens, or PII.
Log level confusion: Using ERROR for expected cases or DEBUG for critical path.
No trace ID propagation: Logs from the same request have different IDs across services.
String interpolation in logs: log.info("user " + user.name) creates string even when level is disabled.
Logging in hot paths without sampling: Every request logs, creating performance issues.