logging
Skill0 starsChanged 32 days agoMITView on GitHub
Add, improve, and fix structured logging in an application. Use when the user asks to add logging, fix noisy logs, improve log output, add structured logs, set up log levels, replace console.log with a real logger, add request tracing, or make logs parseable by a log aggregator like Datadog, CloudWatch, or Loki.
- Reads credentials
25 other projects use a version of this.
Adopted by
Most recently taken up by
- codewithmukesh/dotnet-claude-kittheir own version, first seen Nov 8, 2026
- lawless-m/claude-skillstheir own version, first seen Nov 6, 2026
- zdanovichnick/dotnet-pilottheir own version, first seen Nov 6, 2026
- gabrielbauman/skillstheir own version, first seen Nov 1, 2026
- andr-ca/agentharnesstheir own version, first seen Oct 15, 2026
- syntropic137/software-leverage-pointstheir own version, first seen Oct 14, 2026
Used with
Projects with it also use convention-learner, opentelemetry and 6 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
codewithmukeshSkillconvention-learner
Detects and enforces project-specific coding conventions by analyzing existing codebase patterns. Learns naming conventions, folder structure, test organization, and coding style from the existing code. Load when: "conventions", "coding standards", "project patterns", "enforce style", "detect patterns", "learn conventions", "code consistency".
Also in 3 projects that use this
codewithmukeshSkillopentelemetry
OpenTelemetry observability for .NET 10 applications. Covers traces, metrics, and logs using the OpenTelemetry SDK with OTLP export. Includes custom ActivitySource, IMeterFactory metrics, resource configuration, and Aspire Dashboard integration. Load this skill when setting up distributed tracing, custom metrics, OTLP export, or when the user mentions "OpenTelemetry", "OTLP", "traces", "spans", "Activity", "ActivitySource", "metrics", "IMeterFactory", "Meter", "Counter", "Histogram", "Gauge", "telemetry", "observability", "distributed tracing", "OTEL", or "Aspire Dashboard".
Also in 3 projects that use this
MovGP0Skillmodern-csharp
Modern C# style guidance for Bendex and MicroSea code changes, including primary constructors, expression-bodied members, var usage, target-typed new, lambdas, and pattern matching.
Also in 3 projects that use this
junhjangSkillconfiguration
Adding a new config file, adding a field, or wiring a config consumer. Enforces schema validation at startup (no permissive defaults), env-var indirection for secrets, layered config (defaults / per-env / operator-override), hot-reload explicit per field.
Also in 4 projects that use this
MicrosoftSkillresilience
Apply resilience patterns (retry, backoff, circuit breaking) when writing or reviewing code that makes outbound HTTP/REST calls, database operations, or any I/O that can experience transient failures. Use this skill when: (1) writing new code that calls external services or APIs, (2) reviewing code that uses fetch, HTTP clients, or service-to-service calls, (3) adding queue consumers or workers that interact with remote systems, (4) debugging intermittent failures in production.
Also in 3 projects that use this
hongyuancSkillvertical-slice
Build and evaluate a production-quality vertical slice before advancing from Pre-Production to Production.
Also in 3 projects that use this
Other versions25 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 25
- elie222/inbox-zero★ 13ksame name
- lukevella/rallly★ 5.4ksame name
- epicenter-md/epicenter★ 4.8ksame name
- EpicenterHQ/epicenter★ 4.8ksame name
- golemcloud/golem★ 1.5ksame name
- codewithmukesh/dotnet-claude-kit★ 808same name
- emavgl/oinkoin★ 486same name
- QuantConnect/Documentation★ 268same name
- Resgrid/Core★ 238same name
- lawless-m/claude-skills★ 6same name
15 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository68 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- accessibilitySkill
- api-designSkill
- api-versioningSkill
- authSkill
- background-jobsSkill
- cachingSkill
- capacity-planningSkill
- changelogSkill
- chaos-engineeringSkill
- ci-cdSkill
- circuit-breakerSkill
- claude-best-practicesSkill
- code-commentsSkill
- code-hygieneSkill
- code-reviewSkill
- code-structureSkill
- commit-styleSkill
- concurrency-and-lockingSkill
- database-transactionsSkill
- data-consistencySkill
- debug-infra-startupSkill
- debug-sessionSkill
- demo-video-creatorSkill
- demo-video-script-creatorSkill
- dependency-injectionSkill
- dependency-updateSkill
- disk-cleanupSkill
- distributed-tracingSkill
- dockerSkill
- env-configSkill
- env-setupSkill
- error-handlingSkill
- event-driven-architectureSkill
- feature-flagsSkill
- file-storageSkill
- graceful-shutdownSkill
- idempotencySkill
- input-validationSkill
- jars-engineering-blogsmithSkill
- jars-workshop-builderSkill
- licensingSkill
- memory-and-allocationsSkill
- migrate-dbSkill
- monitoringSkill
- multi-tenancySkill
- notificationsSkill
- openapiSkill
- paginationSkill
- perf-profileSkill
- pr-descriptionSkill
- query-optimizationSkill
- rate-limitingSkill
- refactorSkill
- releaseSkill
- runbook-writerSkill
- searchSkill
- secrets-auditSkill
- simplifySkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 6 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 20 edited versions we read keep these.
6
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Add logs that help you diagnose production incidents in minutes, not hours.
- Distinctive: line 13
Read the codebase before adding logs: Check what logger is already in use.
- Distinctive: line 21
Logs are for operators, not developers: Write messages that help someone who didn't write the code understand what happened and why.
- Distinctive: line 38
If a logger exists, use it.
- Very specific: line 82
Never use string interpolation: logger.info("User " + id + " logged in") — that's unparseable.
- Distinctive: line 220
Don't log the same error multiple times as it bubbles up the call stack — one log per error at the boundary where you decide what to do …
- Distinctive: line 222
Always include context: IDs, operation names, relevant input values (scrubbed).
- Very specific: line 237
Use your logger's redact option (pino) or a scrubber middleware rather than manually checking every log call.
- Very specific: line 244
When you find raw console.log or print calls, replace them:
- Very specific: line 256
Do this incrementally — replace a file at a time, verify the output, commit.
“Common” is measured: kept by at least 6 in 10 of the 20 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Logging
Add logs that help you diagnose production incidents in minutes, not hours. Logs that are too noisy are as useless as no logs — the goal is the right information at the right level.
Ground rules
- Read the codebase before adding logs. Check what logger is already in use. Never introduce a second logging library into a project that already has one.
- Use structured logging. Key-value pairs or JSON, not interpolated strings. Aggregators (Datadog, CloudWatch, Loki, Splunk) can filter and alert on fields; they cannot parse sentences.
- Never log secrets, PII, or credentials. Scrub before logging: passwords, tokens, full credit card numbers, SSNs, raw request bodies that may contain any of the above.
- Pick the right level. A miscategorised level destroys the signal-to-noise ratio.
- Logs are for operators, not developers. Write messages that help someone who didn't write the code understand what happened and why.
Step 0: Check what's already there
# Find the existing logger
grep -r "require.*logger\|import.*logger\|from.*logging\|winston\|pino\|bunyan\|log4j\|zap\|slog\|sentry" \
--include="*.ts" --include="*.js" --include="*.py" --include="*.go" -l | head -10
# Check for raw console/print usage that should be replaced
grep -rn "console\.log\|console\.error\|print(\|fmt\.Print" \
--include="*.ts" --include="*.js" --include="*.py" --include="*.go" | head -20If a logger exists, use it. Read its configuration before adding anything.
Log levels — when to use each
| Level | Use it for |
| ERROR | Something failed and a human needs to act. Unexpected exceptions, failed payments, data corruption. |
| WARN | Something unexpected happened but the system recovered. Deprecated API usage, retried operations, config fallbacks. |
| INFO | Normal significant events. Service started, user logged in, job completed, request served. |
| DEBUG | Detail useful during development or incident investigation. Query params, intermediate values, branch decisions. Off in production by default. |
| TRACE | Very fine-grained: every function call, loop iteration, raw payloads. Never on in production. |
The most common mistake: using ERROR for expected user errors (validation failures, 404s)
and INFO for every line of code. Both destroy the signal.
Structured logging patterns
Node.js — pino (preferred) or winston
// Setup — do this once, export the logger
import pino from "pino";
export const logger = pino({
level: process.env.LOG_LEVEL ?? "info",
// In production, output raw JSON. In dev, use pino-pretty for human output.
transport:
process.env.NODE_ENV !== "production"
? { target: "pino-pretty", options: { colorize: true } }
: undefined,
// Redact sensitive fields wherever they appear in log objects
redact: ["req.headers.authorization", "body.password", "body.token", "*.creditCard"],
});
// Usage
logger.info({ userId: user.id, plan: user.plan }, "User upgraded plan");
logger.error({ err, orderId }, "Payment failed"); // pino serializes err automatically
logger.debug({ query, params }, "Running query");Never use string interpolation: logger.info("User " + id + " logged in") — that's
unparseable. Always pass a context object as the first argument.
Python — structlog (preferred) or standard logging
# Setup
import structlog
import logging
logging.basicConfig(
format="%(message)s",
level=logging.getLevelName(os.getenv("LOG_LEVEL", "INFO")),
)
structlog.configure(
processors=[
structlog.contextvars.merge_contextvars,
structlog.stdlib.add_log_level,
structlog.stdlib.add_logger_name,
structlog.processors.TimeStamper(fmt="iso"),
structlog.processors.JSONRenderer(), # swap for ConsoleRenderer() in dev
],
wrapper_class=structlog.make_filtering_bound_logger(logging.root.level),
logger_factory=structlog.stdlib.LoggerFactory(),
)
log = structlog.get_logger()
# Usage
log.info("user.plan_upgraded", user_id=user.id, plan=user.plan)
log.error("payment.failed", order_id=order_id, error=str(e))
log.debug("db.query", sql=query, params=params)Go — slog (stdlib, Go 1.21+) or zap
// Setup with slog (no dependency)
import "log/slog"
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
Level: slog.LevelInfo,
}))
slog.SetDefault(logger)
// Usage
slog.Info("user.plan_upgraded", "user_id", userID, "plan", plan)
slog.Error("payment.failed", "order_id", orderID, "err", err)
slog.Debug("db.query", "sql", query)Request logging (HTTP)
Log every inbound request at INFO with: method, path, status code, duration, and a request/trace ID. Do not log request bodies by default — they may contain PII.
Express / Node.js
import { randomUUID } from "crypto";
app.use((req, res, next) => {
const requestId = (req.headers["x-request-id"] as string) ?? randomUUID();
const start = Date.now();
// Attach a child logger with the request ID bound to every log in this request
req.log = logger.child({ requestId });
res.on("finish", () => {
req.log.info(
{
method: req.method,
path: req.path,
status: res.statusCode,
durationMs: Date.now() - start,
},
"request completed"
);
});
next();
});FastAPI / Python
import time, uuid
from fastapi import Request
@app.middleware("http")
async def log_requests(request: Request, call_next):
request_id = request.headers.get("x-request-id", str(uuid.uuid4()))
start = time.perf_counter()
with structlog.contextvars.bound_contextvars(request_id=request_id):
response = await call_next(request)
log.info(
"request.completed",
method=request.method,
path=request.url.path,
status=response.status_code,
duration_ms=round((time.perf_counter() - start) * 1000, 2),
)
return responseError logging
Log errors with the full stack trace and enough context to reproduce:
// Node.js — pino serialises err correctly when passed as a field
try {
await processOrder(orderId);
} catch (err) {
logger.error({ err, orderId, userId }, "Order processing failed");
throw err; // re-throw; don't swallow unless you have a recovery path
}# Python — structlog + exc_info captures the traceback
try:
process_order(order_id)
except Exception:
log.error("order.processing_failed", order_id=order_id, exc_info=True)
raiseRules:
- Log at the point where the error is handled, not where it propagates.
- Don't log the same error multiple times as it bubbles up the call stack — one log per error at the boundary where you decide what to do with it.
- Always include context: IDs, operation names, relevant input values (scrubbed).
What not to log
| Don't log | Reason |
| Passwords, tokens, API keys | Secrets in logs are a security incident |
| Full credit card numbers, SSNs | PII / compliance (PCI-DSS, GDPR) |
| Raw request/response bodies | May contain any of the above |
| Every function entry/exit at INFO | Noise that buries real events |
| Stack traces at DEBUG | Use ERROR or WARN for exceptions |
| IDs that are UUIDs at TRACE everywhere | Only useful if a bug is already known |
Use your logger's redact option (pino) or a scrubber middleware rather than manually
checking every log call.
Replacing console.log / print
When you find raw console.log or print calls, replace them:
// Before
console.log("Starting job", jobId);
console.error("Failed:", err);
// After
logger.info({ jobId }, "Job started");
logger.error({ err, jobId }, "Job failed");Do this incrementally — replace a file at a time, verify the output, commit. Don't
replace every console.log in the repo in one pass.
Log aggregator output format
For Datadog, CloudWatch, Loki, or any aggregator, output must be JSON on stdout:
{"level":"info","time":"2024-01-15T10:30:00.123Z","requestId":"abc-123","userId":"42","msg":"User upgraded plan","plan":"pro"}Key fields every line should have:
level— string (info,error, etc.)time— ISO 8601 timestampmsg— human-readable description of the eventservice— name of the service (set once at logger init, not per call)- Any IDs relevant to the operation (
userId,orderId,requestId)
Checklist
- Existing logger found and used — no second library introduced
- All
console.log/printreplaced with structured logger calls - Context object passed as first arg, message as second (
logger.info({...}, "msg")) - Log levels match severity — no
ERRORfor 404s, noINFOfor every function call redactor scrubber configured for passwords, tokens, PII- Every HTTP request logs method, path, status, duration, and request ID
- Errors logged with full context at the handling boundary, not at every layer
- Output is JSON in production, human-readable in development
LOG_LEVELconfigurable via environment variable
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.

