Skip to content
terrylica avatar

Python Logging Best Practices

Python logging guide covering loguru, structlog, orjson, and a zero-dependency JSONL telemetry pattern with rotation.

CCM score
55 of 100
skills.sh installs
411
GitHub stars
5
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers choosing a logging approach by scale: zero-dep JSONL, loguru, structlog with OpenTelemetry, stdlib, and Logfire
  • Includes a complete zero-dependency telemetry logger with size-based rotation via telemetry.jsonl and journald-captured print output
  • Enforces a token fingerprinting rule so secrets never enter the logging pipeline, instead of relying on regex redaction
  • Designed for single-server services and containerized apps that need structured, machine-readable logs for analysis

Install

$ npx -y skills add terrylica/cc-skills --skill python-logging-best-practices -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Python Logging Best Practices

Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.

When to Use This Skill

Use this skill when:

  • Setting up Python logging for any service or script
  • Configuring structured JSONL logging for analysis
  • Implementing log rotation
  • Choosing between lightweight (zero-dep) and full-featured logging
  • Adding logging to containerized, systemd, or local applications

Overview

Unified reference for Python logging patterns optimized for machine readability (Claude Code analysis) and operational reliability. Starts with the lightest viable approach and scales up only when needed.

Decision Heuristic: Start Light, Scale Up

Is it < 5 services on a single machine, < 1 event/sec?
  YES → Lightweight Pattern (print + JSONL telemetry)
  NO  → Is it containerized / serverless?
    YES → stdout JSON (any library), no file rotation
    NO  → Is OTel tracing required?
      YES → structlog + OTel
      NO  → loguru (CLI tools) or stdlib RotatingFileHandler

Details

Repository
github.com/terrylica/cc-skills
Categories
Python, DevOps & Cloud, Debugging
First seen
Jun 3, 2026

Questions

How do I install the python-logging-best-practices skill?

Run npx -y skills add terrylica/cc-skills --skill python-logging-best-practices -y in your project. The skill then lets your agent set up Python logging with loguru, structlog and orjson, following its trigger terms.

Where does python-logging-best-practices rank in its category?

It sits in the Python category on Claude Marketplaces and ranks in the top 100 there. Other skills in that category include python-performance-optimization, python-design-patterns and async-python-patterns.

When should I use python-logging-best-practices?

Use it when setting up Python logging for a service or script, configuring structured JSONL logging, or implementing log rotation. It also helps choose between a lightweight zero-dependency approach and a full-featured library like loguru or structlog.

Does python-logging-best-practices avoid logging secrets?

Yes, its lightweight pattern logs a non-reversible token fingerprint instead of the full token. The skill argues this keeps secrets out of the logging pipeline entirely rather than relying on regex redaction.

More from terrylica/cc-skills

All 3

Similar to Python Logging Best Practices

More Python