awesome-logging-standards
Skill12 starsChanged 2 months agoMITView on GitHub
Applies structured logging: levels, PII redaction, request logging, wide events (canonical log lines). Use when adding or reviewing logs, choosing levels, or after logs failed or leaked data in an incident.
In this repository48 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- awesome-accessibility-auditSkill
- awesome-agents-md-generatorSkill
- awesome-api-designSkill
- awesome-architecture-auditSkill
- awesome-bug-fixSkill
- awesome-claims-auditSkill
- awesome-code-cleanupSkill
- awesome-code-docsSkill
- awesome-code-explainerSkill
- awesome-code-review-feedbackSkill
- awesome-code-review-jurySkill
- awesome-code-reviewSkill
- awesome-code-standardsSkill
- awesome-content-campaignSkill
- awesome-content-image-adapterSkill
- awesome-content-publisherSkill
- awesome-content-repurposeSkill
- awesome-content-voiceSkill
- awesome-copywritingSkill
- awesome-database-auditSkill
- awesome-dependency-auditSkill
- awesome-dependency-upgradeSkill
- awesome-design-docSkill
- awesome-document-styleSkill
- awesome-error-standardsSkill
- awesome-git-author-rewriteSkill
- awesome-git-commit-planSkill
- awesome-git-history-rebuildSkill
- awesome-git-history-resetSkill
- awesome-git-history-salvageSkill
- awesome-grammar-checkSkill
- awesome-humanize-enSkill
- awesome-landing-auditSkill
- awesome-leak-auditSkill
- awesome-pentestSkill
- awesome-performance-auditSkill
- awesome-regression-sweepSkill
- awesome-root-causeSkill
- awesome-security-auditSkill
- awesome-seo-auditSkill
- awesome-skills-purgeSkill
- awesome-slop-auditSkill
- awesome-style-mimicSkill
- awesome-test-writingSkill
- awesome-translate-ru-enSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 9 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
After an incident where logs were insufficient or leaked data
- Distinctive: line 27
Verify the telemetry itself — After instrumenting, induce the failure and confirm you can locate it from the logs/metrics alone.
- Distinctive: line 30
No secrets — Never log passwords, tokens, API keys, or full card numbers.
- Distinctive: line 35
Check existing practice — What format does the project use (JSON, plain text)?
- Distinctive: line 37
Add context — Request id, operation name, duration, status.
- Distinctive: line 39
Verify — Logs go to stdout or the configured sink.
- Distinctive: line 98
Do not add logs that dump full request/response or env vars.
- Distinctive: line 99
If the project has a logging or privacy policy (retention, PII, secrets), align with it.
- Distinctive: line 100
Use the same library and format as the rest of the codebase.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Logging Standards
Apply consistent logging so operations are debuggable and compliant without leaking secrets or PII.
When to Activate
- Adding or refactoring log statements
- User asks for "logging", "log format", or "what to log"
- Defining or reviewing logging standards for the project
- After an incident where logs were insufficient or leaked data
Core Principles
- Define "working" before instrumenting — Write the 2–4 questions on-call will actually ask ("did checkout succeed for this user?", "which dependency is slow?") and make every signal map to one of them. A log line that answers no operational question is noise.
- Structured — Prefer key-value fields (e.g. JSON) over long prose so logs are queryable and parseable. Use the same structure across the app (timestamp, level, message, fields).
- Cardinality — Never use unbounded values as index/label keys (user_id, email, full URL, raw error text) in metrics/labels — they explode cardinality; keep them as event fields instead. Alert on symptoms (user-visible failure), not causes (one host's CPU).
- Verify the telemetry itself — After instrumenting, induce the failure and confirm you can locate it from the logs/metrics alone. Untested observability tends to be silently wrong — e.g. sampling upstream of metric generation skews a request-rate metric by the sampling ratio while nothing looks broken.
- Levels — Use consistently: ERROR (failures, exceptions), WARN (recoverable issues, deprecations), INFO (key business events, request summary), DEBUG (detailed flow; disable or sample in production).
- Context — Include request_id, trace_id, or correlation_id when available. Include user_id, order_id, or similar only when safe and allowed by policy. Do not log full PII (email, phone, address) in plain text unless required and compliant.
- No secrets — Never log passwords, tokens, API keys, or full card numbers. Redact or omit. For debugging, mask or show last 4 digits only where policy allows.
- One place — Use the project's logging library (Winston, Pino, log4j, structlog, etc.) and output to the same pipeline (e.g. stdout) that the platform collects.
Work Process
- Check existing practice — What format does the project use (JSON, plain text)? What library? What levels? Match it.
- Choose level — error for failures; warn for recoverable or deprecated; info for key actions (request completed, order created); debug for detailed flow. Do not use info for verbose per-item logs in hot paths; use debug or sampled info.
- Add context — Request id, operation name, duration, status. Identifiers (user_id, order_id) only if policy allows. Structured fields, not interpolated into message string when the logger supports structured fields.
- Redact — No secrets; no full PII in message or fields. If you must log something sensitive for debugging, use redaction or sampling and document.
- Verify — Logs go to stdout or the configured sink; format is parseable; no secrets or PII in sample output.
What to Log
| Category | Level | Content | Do not log |
| Request start/end | INFO | method, path, status, duration_ms, request_id | Body, headers with tokens |
| Errors | ERROR | message, error type, stack (server-side), request_id | Full request/response, secrets |
| Recoverable issues | WARN | message, context (e.g. retry count), request_id | |
| Key business events | INFO | event name, relevant ids (order_id, user_id if safe), outcome | Full payloads, PII |
| External calls | INFO or DEBUG | service, operation, duration_ms, outcome (success/failure) | Full request/response, credentials |
| Detailed flow | DEBUG | step, state, ids | Secrets, PII |
Format (structured)
JSON (recommended for production):
{
"timestamp": "2024-03-15T10:30:00.123Z",
"level": "info",
"message": "Request completed",
"request_id": "abc-123",
"method": "GET",
"path": "/api/orders",
"status": 200,
"duration_ms": 45
}Fields: Prefer consistent names (snake_case or camelCase per project). Put variable data in fields, not only in the message string, so logs are queryable.
Wide events (canonical log lines)
For request-driven services, prefer one context-rich structured event per request per service over scattered log lines:
- Middleware creates the event and owns timing, status, and emission — emit in
finallyso failures still produce the event. Handlers only add business fields along the way. - Include environment fields in every event: commit hash, service version, region.
- Capture business context, not just mechanics: "premium customer failed a $2,499 checkout" beats "checkout failed".
- Scattered step-by-step lines stay at debug level; the wide event is the queryable record of what happened.
Good vs Bad
Good:
logger.info({ request_id, method, path, status, duration_ms }, 'Request completed');
logger.error({ err, request_id }, 'Payment failed');
logger.debug({ order_id, step: 'validation' }, 'Validating order');Bad:
console.log('User ' + user.email + ' did something'); // PII in log
logger.info('Token: ' + token); // Secret in log
logger.error('Error: ' + err); // May include stack or internal detail in message; use structured fieldRules
- Do not add logs that dump full request/response or env vars. Suggest redaction or sampling if needed for debugging.
- If the project has a logging or privacy policy (retention, PII, secrets), align with it.
- Use the same library and format as the rest of the codebase. Do not introduce a second logging system without good reason.
Checklist
- Level appropriate (error/warn/info/debug)
- Context included (request_id, operation, duration where relevant)
- No secrets or full PII in message or fields
- Structured format (fields) when logger supports it
- Matches project library and format
Anti-patterns
| Anti-pattern | Better approach |
| Logging full request/response | Log method, path, status, duration; redact or omit body/headers |
| Using console.log in server code | Use project logger with levels and structure |
| Interpolating everything into message | Use structured fields (request_id, order_id, etc.) |
| Logging at info for every iteration in a loop | Use debug or sample (e.g. every Nth) |
Leftover print-debugging (print(), fmt.Println, console.log) in production paths | Remove, or convert to logger.debug with fields |
| "We'll redact later" | Redact or omit from the start; do not log secrets |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

