fastapi-logging

Configure structured JSON logging with correlation IDs for FastAPI applications.

3|Updated Jan 20, 2026
One-click install
npx skills add https://github.com/agusmdev/burntop --skill fastapi-logging
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fastapi-logging
Source: https://github.com/agusmdev/burntop/tree/main/.claude/skills/fastapi-logging
Command: npx skills add https://github.com/agusmdev/burntop --skill fastapi-logging

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enables structured JSON logging with automatic correlation IDs for FastAPI applications, improving observability and traceability across requests.

Core Features & Use Cases

  • Structured JSON log output with timestamp, level, logger, and correlation_id for easy analysis.
  • CorrelationIdMiddleware to generate or propagate a unique request ID across services.
  • Early boot configuration via setup_logging() to standardize logs before app startup.
  • Usage in services can utilize get_logger(name) to emit context-rich logs.

Quick Start

Install dependencies (e.g., python3 -m pip install fastapi uvicorn python-json-logger) and add in your FastAPI app:

  • Call setup_logging() before creating the FastAPI instance.
  • Add CorrelationIdMiddleware to the app.
  • Use get_logger to emit structured logs.

Frequently Asked Questions about fastapi-logging

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

FAQPage Schema
How do I configure structured JSON logging in a FastAPI application?

Configure structured JSON logging in FastAPI by calling setup_logging() before app creation and adding CorrelationIdMiddleware. This standardizes log outputs with timestamps, levels, and correlation IDs across request handling contexts.

How do I trace requests across distributed FastAPI services?

Trace requests across distributed FastAPI services by applying CorrelationIdMiddleware to generate and propagate a unique correlation ID. This ID links related log entries across different services into a single traceable request flow.

Why do I need structured logging for FastAPI middleware?

Structured logging for FastAPI middleware provides consistent JSON outputs containing timestamp, level, logger, and correlation_id. This format enables easy parsing and analysis when monitoring distributed services and tracing request lifecycles.

Can I use python-json-logger with FastAPI for structured logs?

Use python-json-logger with FastAPI by installing it alongside uvicorn and invoking setup_logging() at early boot. This configures the logger to emit structured JSON formats before the application starts handling requests.

What is the best way to standardize FastAPI logs before startup?

Standardize FastAPI logs before startup by invoking setup_logging() early in the boot process. This utility configures the logging framework globally to ensure consistent structured outputs immediately when the application launches.