logging

Configure Python applications with structlog for JSON and console logging.

Updated Mar 9, 2026
One-click install
npx skills add https://github.com/bswrundquist/devtools --skill logging-bswrundquist
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: logging
Source: https://github.com/bswrundquist/devtools/tree/main/src/devtools/templates/claude/user/.claude/skills/logging
Command: npx skills add https://github.com/bswrundquist/devtools --skill logging-bswrundquist

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires structlog, and includes references (resource) components.

What problem does it solve?

This Skill helps you set up robust and informative logging for your Python applications, ensuring you can effectively monitor and debug them in both development and production environments.

Core Features & Use Cases

  • Structured Logging: Implements structlog for generating JSON logs in production and human-readable logs in development.
  • Standard Library Logging: Provides guidance on using Python's built-in logging module, including JSON formatting and configuration dictionaries.
  • Log Levels & Best Practices: Details appropriate use of log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL) and what to log/not log.
  • Testing Logs: Shows how to capture and assert log output in tests using structlog.testing and pytest's caplog.

Quick Start

Configure your Python application to use structlog for JSON logging in production and console logging in development by calling the configure_logging function at startup.

Frequently Asked Questions about logging

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure Python logging to output JSON in production and readable console logs in development?

Configure Python logging for dual environments by using structlog to generate JSON logs in production and human-readable console logs in development. This approach ensures effective application monitoring and debugging across different environments.

What is the best way to capture and assert log output in Python tests?

Capture and assert log output in Python tests using structlog.testing and pytest's caplog fixture. This allows you to verify log entries during testing to ensure application monitoring behaves as expected.

Does structlog work with the standard Python logging module?

Yes, structlog works with the standard Python logging module. This Skill provides guidance on using the built-in logging module, including JSON formatting and configuration dictionaries, alongside structlog.

How do I use Python log levels effectively for debugging and monitoring?

Use Python log levels effectively by applying DEBUG, INFO, WARNING, ERROR, and CRITICAL according to best practices. This Skill details appropriate use of log levels and what to log or not log for application monitoring.

When do I need structured logging in my Python application?

You need structured logging in Python applications when you require effective monitoring and debugging in production environments. Structured logging provides JSON output for production and console readability for development.

Why use structlog instead of the standard Python logging module for application monitoring?

Use structlog instead of standard Python logging for structured JSON output in production and context binding capabilities. Structlog enhances application monitoring and debugging across different environments while maintaining compatibility with the standard logging module.