question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how can I use fasyapi with async logging? It’s sync logging by python standard lib logging.

First check

  • I added a very descriptive title to this issue.
  • 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.
  • I already read and followed all the tutorial in the docs and didn’t find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.
  • After submitting this, I commit to:
    • Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
    • Or, I already hit the “watch” button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
    • Implement a Pull Request for a confirmed bug.

Example

Here’s a self-contained minimal, reproducible, example with my use case:

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}

Description

  • Open the browser and call the endpoint /.
  • It returns a JSON with {"Hello": "World"}.
  • I would like it to have an extra parameter to teleport me to the moon and back.

The solution you would like

I would like it to have a teleport_to_moon parameter that defaults to False, and can be set to True to teleport me:

from fastapi import FastAPI

app = FastAPI()


@app.get("/", teleport_to_moon=True)
def read_root():
    return {"Hello": "World"}

Describe alternatives you’ve considered

To wait for Space X moon travel plans to drop down long after they release them. But I would rather teleport.

Environment

  • OS: [e.g. Linux / Windows / macOS]:
  • FastAPI Version [e.g. 0.3.0]:

To know the FastAPI version use:

python -c "import fastapi; print(fastapi.__version__)"
  • Python version:

To know the Python version use:

python --version

Additional context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
bobfang1992commented, Oct 28, 2020

How is this related to fastapi then?

2reactions
Mausecommented, Oct 11, 2020

Async logging is very rarely required or desired. Can you explain why you want it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Log4j 2 Lock-free Asynchronous Loggers for Low-Latency ...
Asynchronous Loggers are a new addition in Log4j 2. Their aim is to return from the call to Logger.log to the application as...
Read more >
Asynchronous Logging - java - Stack Overflow
In lot of products you will see the asynchronous logging feature. Logs are accumulated and pushed to log files using a separate thread...
Read more >
Capture the benefits of asynchronous logging - InfoWorld
Conceptually, the asynchronous log service works like this: The client creates a log message (value object) and asks a helper class, JMSLogger ,...
Read more >
Asynchronous Logging With Log4J Part 2 - DZone
The simplest way to enable asynchronous logging in Log4J 2 is to make all loggers async. This involves setting the Log4jContextSelector system ...
Read more >
Welcome to aiologger docs! - GitHub Pages
aiologger aims to be the standard Asynchronous non blocking logging for python and asyncio. Installation¶. pip install aiologger. Testing¶. pipenv install ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found