Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/nedcodes-ok/cursorrules-collection/logginggit clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collectionWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/logging)<a href="https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/logging"><img src="https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/logging.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00480 | $0.00480 |
| Opus 5 | $0.00240 | $0.00240 |
| Sonnet 5 | $0.00096 | $0.00096 |
| Haiku 4.5 | $0.00048 | $0.00048 |
Grade A, and why
logging scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 51 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Logging Cursor Rules
You are an expert at application logging. Follow these rules:
Structured Logging
- JSON logs in production — never printf-style strings
- Every log entry: timestamp, level, message, service, correlation_id
- Use structured fields, not string interpolation: { user_id: 123 } not "user 123"
- Include trace/span IDs for distributed tracing integration
- Logger per module/class with preset context fields
Log Levels
- ERROR: operation failed, needs attention, may need alerting
- WARN: unexpected condition, degraded but functioning
- INFO: significant business events (user created, order placed, deploy started)
- DEBUG: detailed flow for troubleshooting — never in production by default
- Never log at ERROR for expected conditions (user not found, validation failed)
What to Log
- All incoming requests: method, path, status, duration, request_id
- External service calls: target, method, duration, success/failure
- Authentication events: login, logout, failed attempts, token refresh
- Business events: created, updated, deleted with entity IDs
- Errors with full context: input, state, stack trace
What NOT to Log
- Passwords, tokens, API keys, session IDs — ever
- PII unless required and compliant: names, emails, addresses
- Request/response bodies in production (too verbose, PII risk)
- Health check requests — they drown real signals
- Successful routine operations at INFO — keep signal-to-noise ratio high
Correlation
- Generate request_id at the edge (API gateway, load balancer)
- Propagate through all services via headers (X-Request-ID)
- Include in all log entries, error responses, and downstream calls
- User_id and session_id as context fields when authenticated
Operations
- Centralized log aggregation: ELK, Loki, CloudWatch, Datadog
- Log rotation and retention policies — dont fill disks
- Alert on error rate spikes, not individual errors
- Sampling for high-volume debug logs — 1% of requests in production
- Parseable timestamps: ISO 8601 / RFC 3339 always
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 51 lines · 480 tokens per session scan A 7e65884110f0
logging is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (37 stars, last pushed 6mo ago), licensed MIT. It adds 480 tokens to every session, about $0.0024 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other cursor rules, from other repositories
06-error-handling
Cursor rule "06-error-handling" from orbitalsonic/AndroidPilot, covering error handling, never, always, coroutines and validation.
diagnose
Systematic root cause diagnosis — confidence scoring, investigation budgeting, hypothesis branching.
chaos
Failure injection mode — stress test implementations by simulating failures and hostile conditions.
incident
Production incident response — structured triage with blast radius, rollback criteria, and verification.
analyze
Codebase analysis — complexity, coupling, dead code, tech debt hotspots.
10-feature-development
Feature implementation workflow and engineering mindset.