Skip to content
Back to skills

Logging Best Practices

ASecurity

Expert logging guidance based on Boris Tane's loggingsucks.com philosophy.

  • 49 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added February 7, 2026
code-qualityjavascriptjavadebugging

Works with

  • cli

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned February 12, 2026

npx -y skills add ncklrs/startup-os-skills --skill logging-best-practices --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Logging Best Practices?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Logging Best Practices
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ncklrs-logging-best-practices/badge)](https://www.skillsdirectory.com/skills/ncklrs-logging-best-practices)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: logging-best-practices
description: Expert logging guidance based on Boris Tane's loggingsucks.com philosophy.
             Use when implementing logging, adding observability, debugging production issues,
             or reviewing code that includes log statements. Covers wide events architecture,
             structured logging, smart sampling, and high-cardinality field design.
---

# Logging Best Practices

Expert guidance for production-grade logging based on Boris Tane's [loggingsucks.com](https://loggingsucks.com/) philosophy.

## Core Philosophy

**Stop logging "what your code is doing." Start logging "what happened to this request."**

Traditional logging is optimized for *writing*, not *querying*. Developers emit logs for immediate debugging convenience without considering how they'll be searched later. This creates massive signal-to-noise ratios at scale.

## The Wide Events Architecture

Instead of scattered log statements throughout your code, build **one comprehensive event per request per service**:

```javascript
// ❌ Traditional scattered logging
logger.info("Request started");
logger.info(`User ${userId} found`);
logger.info("Fetching cart");
logger.debug(`Cart has ${items.length} items`);
logger.info("Processing payment");
logger.error(`Payment failed: ${error.message}`);

// ✅ Wide event - build throughout request, emit once
const event = {
  request_id: req.id,
  timestamp: Date.now(),
  service: "checkout",
  version: "2.3.1",

  user: { id: userId, tier: "premium", account_age_days: 847 },
  cart: { id: cartId, item_count: 3, total_cents: 15999 },
  payment: { method: "card", provider: "stripe", latency_ms: 234 },

  outcome: "failure",
  error: { type: "PaymentDeclined", code: "card_declined", retriable: true }
};

logger.info(event);
```

## Key Concepts

| Concept | Definition |
|---------|------------|
| **Wide Event** | One comprehensive, context-rich log per request per service |
| **Cardinality** | Number of unique values (user IDs = high, HTTP methods = low) |
| **Dimensionality** | Count of fields per event (aim for 40+ meaningful fields) |
| **Tail Sampling** | Sample decisions after request completion based on outcomes |

## When to Apply This Skill

- Implementing logging in new services
- Reviewing code with log statements
- Debugging production issues
- Designing observability strategy
- Migrating from printf-style to structured logging
- Reducing log volume while improving queryability

## What This Skill Provides

1. **Wide event patterns** for different frameworks and languages
2. **Field design guidance** for high-cardinality debugging
3. **Sampling strategies** that preserve signal
4. **Anti-pattern detection** in existing logging code
5. **Query-first thinking** for log architecture

Files in this skill

  • SKILL.md2.7 KB
  • rules/_sections.md910 B
  • rules/antipattern-otel-silver-bullet.md4.1 KB
  • rules/antipattern-scattered-logs.md3.7 KB
  • rules/antipattern-string-search.md3.6 KB
  • rules/architecture-event-lifecycle.md4 KB
  • rules/architecture-wide-events.md2.7 KB
  • rules/fields-business-context.md3.9 KB
  • rules/fields-high-cardinality.md3.5 KB
  • rules/fields-required-context.md3.5 KB
  • rules/sampling-always-keep.md3.9 KB
  • rules/sampling-tail-sampling.md3.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…