# Logging an API

A server's code reports what it does through Python's logging module instead of print, with a logger per module, levels from DEBUG to ERROR, a format with the time and level, one line for every request written by a middleware, and a logging.Filter that keeps passwords and tokens out of every line.

![Cheat sheet: Logging an API](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/2fc7055604664128ae913b2833799a82.webp)

- Category: FastAPI
- Level: Journeyman
- Tags: fastapi, Log Redaction, Logging Levels, logging Module, Middleware (fastapi), rest-api
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/fastapi-pro-logging-cheat-sheet
