Fastapi: how to pass a custom logger to the fastapi app

Created on 8 Jan 2020  路  3Comments  路  Source: tiangolo/fastapi

First check

  • [ ] I used the GitHub search to find a similar issue and didn't find it.
  • [ ] I searched the FastAPI documentation, with the integrated search.
  • [ ] I already searched in Google "How to X in FastAPI" and didn't find any information.

Description

Great! The performance of fastApi is impressive. I am going to deploy it. And I want to custom a logger. Can I pass it to the app?

question

Most helpful comment

You can use logger like loguru. It has InterceptHandler that can help you to customize all logs.

Also you can see configuration example here

All 3 comments

You can use logger like loguru. It has InterceptHandler that can help you to customize all logs.

Also you can see configuration example here

Yep, what @Slyfoxy said.

You can get the logger with:

import logging

logger = logging.getLogger("fastapi")

Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tsdmrfth picture tsdmrfth  路  3Comments

KoduIsGreat picture KoduIsGreat  路  3Comments

zero0nee picture zero0nee  路  3Comments

mr-bjerre picture mr-bjerre  路  3Comments

kkinder picture kkinder  路  3Comments