
Python Logging Best Practices
This is a practical reference for Python logging that starts with the lightest approach and scales up only when needed. The standout pattern is a zero-dependency dual-channel setup: print statements go to systemd journald for ops, while a separate JSONL file captures structured telemetry for machine analysis. It includes a smart token fingerprinting technique that logs only a mid-section slice of secrets, avoiding the regex redaction trap entirely. The decision tree helps you pick between lightweight patterns, loguru, structlog, or stdlib based on your actual scale and deployment model. Good for anyone tired of overengineered logging setups or dealing with credentials accidentally hitting logs.
- skills.sh installs
- 406
- GitHub stars
- 2
- last updated
- Aug 21, 2026
Install
$ npx -y skills add terrylica/cc-skills --skill python-logging-best-practices --agent claude-codeInstalls into .claude/skills of the current project.
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
Sponsors
Details
- Repository
- github.com/terrylica/cc-skills
- Categories
- DevOps & CI/CD, Python
- First seen
- Jun 3, 2026