logging

logging is a cursor rule for Cursor from nedcodes-ok/cursorrules-collection. It costs 480 tokens per session, scanned A, original, MIT.

A set of rules for producing structured application logs with consistent fields, levels, and request or trace identifiers. Structured logs are machine-readable records that are easier to search and analyze.

In plain words
What is it for?
Use it to define production log formats, record requests and external calls, classify events, and keep passwords, tokens, and keys out of logs.
Why use it?
It makes failures and user activity easier to trace across services while reducing noisy or sensitive log output.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: mentions Cursor.

Install

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.

agentmods
npx agentmods add rules/nedcodes-ok/cursorrules-collection/logging
Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collection

Made for: Cursor.

Wrote 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.

agentmods badge for logging

README.md
[![agentmods](https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/logging.svg)](https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/logging)
Your own site
<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>
Per session 480 This file is loaded in full into every session.
When invoked 480 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 2d ago against content hash 7e65884110f0, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

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.

rules-mdc/practices/logging.mdc · 51 lines

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

Read the full file on GitHub · 51 lines

Changes

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.

  1. 2d ago First seen · 51 lines · 480 tokens per session scan A 7e65884110f0

Subscribe to this mod's changes

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.